correcting the sort