You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use optimal in-place sorting for ranges of size 5 and smaller. This first minimizes maximum and average number of comparisons (these two goals never conflict at this size), then minimizes comparisons for already sorted inputs, then minimizes comparisons for reverse sorted inputs.
With this new code, there is not an advantage to the hybrid approach I made for sorting 6 elements, so that is currently disabled. There is still work to be done here to optimize small ranges that are larger than the hand-coded algorithms.
For ranges that are large, have non-trivial element types, or use a comparison function other than `std::less` and `std::greater`, assume comparisons are expensive and use an algorithm that minimizes comparisons, otherwise use an algorithm that performs best for types like `int`.
These small sorting algorithms perform much better than existing standard library implementations for all types tested.
0 commit comments