Sorting improvements