A C++ Quicksort Faster Than std:sort
Web page · https://tiki.li/blog/about_blqsort
First seen by Oriel on .
AI summary
blqsort is an MIT-licensed, general-purpose C++ quicksort combining branchless partitioning, sorting networks, and robust pivot selection to outperform std::sort in the presented random-data benchmarks.
- Sorting 50 million random doubles took blqsort 0.67s on Apple M1 and 1.33s on Intel i5-9300H, versus std::sort's 1.33s and 4.97s.
- For 50 million entry structs, blqsort took 0.75s on M1 and 1.40s on Intel, while std::sort took 3.45s and 4.10s.
- It partitions blocks through an auxiliary buffer without data-dependent branches and uses sorting networks for partitions up to 16 elements.
- Pivot selection combines several medians with randomness; highly uneven partitions fall back to heap sort, while duplicate keys are detected and grouped.
- The single-header implementation supports arbitrary data types and custom comparisons; C and multithreaded versions are also available, with M1 multithreading roughly three times faster.
#c++ #sorting algorithms #branchless programming #performance optimization
Generated by gpt-5.6-sol. Check the original for details.
Metric trends
Last 30 days · Up to 120 recorded samples per source and metric, with reposts kept separate · First and latest retained
Points
Score reported by the source.
- Hacker News: 36, latest observation ; +23 over observed period since
- Lobsters: 23, latest observation ; +22 over observed period since
Comments
Comment count reported by the source.
- Hacker News: 10, latest observation ; +7 over observed period since
- Lobsters: 2, latest observation ; +2 over observed period since
Aliases
| Source | External ID | URL |
|---|---|---|
| Hacker News | 50436788 | https://tiki.li/blog/about_blqsort Read discussion |
| Lobsters | qi2lni | https://tiki.li/blog/about_blqsort Read discussion |