Histogram is a statistical tool. An important observation is that two or more images can have the same histogram. In our experiment we have an original image shown below on the left and a sorted version (raster scan ascending order) of the same image show on the right.
--
Original image ---------------- Sorted version
Below is the histogram of both images.