A stable Quicksort that writes less-than elements to the scratch front and greater-than elements to the scratch back in one forward scan, reverses the back section to restore stable order, fills equal elements into the gap, and copies the scratch back. Uses median-of-3 with tail-call elimination.
One-pass bidirectional writing replaces the traditional count-then-distribute approach, reducing comparison work when duplicates are rare. The reverse of the greater-than section is the trade-off cost.