Tidy-up of sorting