corrected sorting order