kexibq-official / cafs-lib
PublicCache-aware frequency sort: a header-only C++20 sort for low-cardinality integer arrays on x86-64.
CAFS is a high-speed sorting library designed specifically for lists of integers where many values repeat. Instead of comparing every item against every other item like traditional sorting, it counts how many times each value appears, then writes them back in order. This approach is 1.7 to 17 times faster than standard sorting for the right data patterns. The library comes with ready-to-use wrappers for Python, Rust, and Go, plus an animated visualization tool that shows exactly how the algorithm works step by step. It's particularly useful for sorting categorical data like status codes, country names, product categories, or any data where the same values appear frequently.
How It Works
You're working with lists like customer categories, status codes, or country names where the same values appear many times.
Standard sorting treats every item equally, but CAFS notices repeated values and counts them first, then writes them back in order.
With a single line of code, you connect CAFS to your Python, Rust, Go, or C++ project.
Pass your list of numbers to CAFS and it automatically picks the fastest approach for your data.
Watch the animated demo showing how the algorithm counts values into buckets, then writes them back in order.
Copy the example code, install the package, and sort your first array in minutes.
CAFS returns your data in order, and for the right kind of data, it can be several times faster than before.
Star Growth
Repurpose is a Pro feature
Generate ready-to-use prompts for X threads, LinkedIn posts, blog posts, YouTube scripts, and more -- with full repo context baked in.
Unlock RepurposeSimilar repos coming soon.