Correct sort function.