A C++ Quicksort Faster Than std:sort

signa11 38 points 11 comments November 10, 2026
tiki.li · View on Hacker News

Discussion Highlights (3 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.

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)

spullara

Fable 5.2 attempted a Lean proof and found a bug in the implementation, it has a fix though: The published blqsort has a bug. In partition, the last loop in the C code only skips elements that are greater than or equal to the pivot. It assumes nothing unsorted is left, and that is false. For example, take 2000 ones with x[1] = 2 and x[2] = 0. The C code returns 0 2 1 1 …, which is not sorted. It fails on about 3 of 4 random seeds. In a C fuzz test of 20,000 random cases, 904 failed. The C++ and threaded versions have the same loop. Because of this bug, no proof can show the published code is correct. https://github.com/chkas/blqsort/issues/4

Semantic search powered by Rivestack pgvector
3,874 stories · 35,194 chunks indexed