optimized sortBy in the case of already sorted lists