Three-way quicksort (source code)

= Three-way quicksort

Partitioning into keys smaller than, equal to and greater than the pivot. Only the smaller and greater partitions need recursive sorting. Keeping the common partition helper in both a direct sorter and a tree-building factorisation ensures that flattening the tree introduces no extra key comparisons.