Reverse sort algorithm for image.