Constant-time parallel sorting algorithm and its optical implementation using smart pixels