Practical quicksort needs 3-way partitioning and recursion-depth detection

srchvrs · x · 2026-11-15

Replying to a nostalgia post featuring an old Pascal quicksort, search engineer srchvrs outlines what production-grade implementations actually do: three-way partitioning plus recursion-depth detection to catch degenerate cases (duplicate-heavy inputs, bad pivots) and fall back to a different algorithm. He notes most modern quicksort implementations work this way, and adds that he once hit pathological slowdowns with an old C++ stdlib sort and switched to merge sort for its guaranteed O(n log n).

Related event: Vintage Pascal quicksort screenshot sparks nostalgia and deep technical discussion(2 posts)→

Original post →

More from coding & agent

coding & agent channel →