A C++ Quicksort That Beats std::sort by Nearly 2x
A C++ Quicksort Faster Than std:sort
blqsort is a new C++ quicksort that outperforms std::sort on random data, sorting 50 million doubles in 0.68s versus 1.33s on an Apple M1. It combines branchless partitioning, sorting networks for small partitions, and robust pivot selection. The MIT-licensed implementation also comes in a single-header C version with multithreaded variants, and handles already-sorted, reverse-sorted, and duplicate-heavy inputs efficiently.
I am not aware of any other general-purpose comparison-based sorting algorithm that is faster on random data.
- omoikane
Previously:
https://news.ycombinator.com/item?id=48375445 - Branchless Quicksort faster than std:sort and pdqsort with C and C++ API (2026-06-02, 82 comments)
- brudgers
Quicksort is quick because it's space requirements are not just linear but very very close to n. It is quick because it minimizes IO.
To be clear I did not look at the code, but benchmarking against 50 million items makes me suspect that minimal IO was required.
Now sure, sometimes that is exactly your use case. But for many interestingly sized problems, IO dominates.