Commit 46afdbe
Add stable LSD radix sort library
Summary:
Add a generalized stable radix sort implementation to folly/algorithm. This extracts and generalizes techniques from the AdInfoStorage radix sort implementation into a reusable library.
The algorithm was initially ideated/implemented by konstantin1, so the credit should go to him for coming up with it.
Key features:
- Stable O(n) LSD (Least Significant Digit) radix sort
- Handles unsigned/signed integers and floating-point types
- Custom key extractors for sorting by struct members
- Ascending and descending order variants
- IEEE 754 to sortable key transformation for floats/doubles
- Alternating buffer pattern to minimize copying
- Falls back to insertion-sort for small inputs (<16 elements)
I ended up doing it because marksantaniello requested it :)
It was `claude`d all the way....
Reviewed By: yfeldblum
Differential Revision: D91785878
fbshipit-source-id: a85fc6a4282a120ef84c7fafff3fbab9d8f300d71 parent beb48e7 commit 46afdbe
File tree
6 files changed
+1091
-0
lines changed- folly/algorithm
- test
6 files changed
+1091
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
25 | 33 | | |
0 commit comments