TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 229 subscribers
Post #24547 16
tieredsort - 3.8x faster than std::sort for integers, header-only

Made a sorting library that detects data patterns before sorting.

Results (n=100k):

Random: 3.8x faster than std::sort, 1.6x faster than ska_sort

Dense data (ages, sensors): 30x faster than std::sort, 9x faster than ska_sort

The idea: real data isn't random. Ages are 0-100. Sensors are 12-bit. When the range is small, counting sort beats everything.

Detection cost: 12 comparisons + 64 samples. Negligible.

C++17, header-only, no SIMD needed.

GitHub: https://github.com/Cranot/tieredsort

Looking for feedback on edge cases I might have missed.

https://redd.it/1pu554f
@r_cpp
GitHub GitHub - Cranot/tieredsort: A fast, header-only C++17 sorting library for numeric types. 3.6x faster than std::sort, up to 21x… A fast, header-only C++17 sorting library for numeric types. 3.6x faster than std::sort, up to 21x on dense data - Cranot/tieredsort
More from @r_cpp
  1. Oct 8, 2026Profiles for simplicity and guarantees - Bjarne Stroustrup - CppCon 2026 https://youtu.be/…
  2. Oct 8, 2026How to Fix autoconf-style Configuration Probing https://build2.org/blog/fix-autoconf.xhtml…
  3. Oct 8, 2026owl – a header-only C++23 HTTP framework where route patterns and handler extractors are c…
  4. Oct 8, 2026Removed by Reddit Removed by Reddit on account of violating the [content policy. ] https:/…
  5. Oct 8, 2026Is there a way to search across all P and N papers throughout standardization history? It…
  6. Oct 8, 2026CppCast Episode 412 : Safety and Interoperability with Rust and C++ https://cppcast.com/sa…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →