How can i calculate the median of an asymmetric histogram (256 gray levels)

you sort it and access the median bin, no ?

be more specific, please