Sorting is broken. Let's refactor