corrected sort