Fix sorting which was broken in the last commit