Repository navigation
Releases
Releases · firedfish285/fast-sort
v0.1
v0.1
English
First release.
Features
- Introsort (worst-case O(n log n)), generated from a single macro template for three element types:
introsort_i64— general-purpose integer sort (negatives supported)introsort_dbl— floating-point sort (NaN not supported)introsort_str— string pointer arrays, lexicographic order- Quicksort core with median-of-three; insertion sort for subarrays ≤ 32; heapsort fallback beyond 2·log₂n recursion depth
- Radix Sort (O(n)):
radix_sort_u64— LSD, 8 bits per pass × 8 passesradix_sort_dbl— IEEE-754 bit-mapping reusing the integer coreradix_sort_str— MSD per-character counting sort
- Built-in correctness tests (fuzz-compared against qsort) and benchmarks:
make test
Build & Run
make
./fast_sortmacOS SDK link issues: make SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX15.4.sdk
Note: the double variants do not support NaN.
简体中文
首个版本。
功能
- 内省排序(Introsort):最坏 O(n log n),一套宏模板生成三种元素类型:
introsort_i64:通用整型排序(含负数)introsort_dbl:浮点排序(不支持 NaN)introsort_str:字符串指针数组,字典序- 快速排序为主体(三数取中);子数组 ≤ 32 切换插入排序;递归过深自动转堆排序
- 基数排序(Radix Sort):O(n)
radix_sort_u64:LSD,8 位一趟共 8 趟radix_sort_dbl:IEEE 754 位技巧复用整数核心radix_sort_str:MSD 逐字符计数排序
- 内置正确性测试(与 qsort 模糊对比)与基准测试:
make test
编译运行
make
./fast_sortmacOS SDK 链接问题:make SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX15.4.sdk
备注:double 版本不支持 NaN。