Vertical Pixel Sorting on image

How I can “rotate the image 90 degrees, sort its rows horizontally, then rotate the image back again” ?