scandum/blitsort
FreeBlitsort is an in-place stable adaptive rotate mergesort / quicksort.
About scandum/blitsort
Blitsort is an in-place stable adaptive rotate mergesort/quicksort, implemented in C and designed for high performance sorting of arrays. It extends the concepts from the out-of-place stable merge sort quadsort, the stable quicksort fluxsort, and the unstable in-place crumsort. Blitsort uses a rotate merge sort approach: it partitions two sorted arrays until they are small enough to be merged using auxiliary memory, employing array rotations (via the efficient trinity rotation algorithm) and a monobound binary search for faster partitioning. The algorithm dynamically analyzes the input data distribution using the same analyzer as fluxsort: fully sorted or reverse-sorted data is handled immediately, mostly sorted data uses rotate quadsort, and random data uses rotate fluxsort (a stable rotate quicksort). By default, blitsort uses 512 elements of stack memory, but can be configured to use as few as 32 elements or sqrt(n) memory, plus O(log n) recursion depth. Performance is claimed to be about 15–50% faster than octosort (a block merge sort) and comparable to fluxsort when sufficient auxiliary memory is available.
Key Features
Pros & Cons
- Faster than many existing in-place stable sorts (e.g., octosort) by 15–50%
- Stable sort preserves original order of equal elements
- Adaptive: near-linear performance on already sorted or reverse-sorted data
- Low memory footprint (as low as 32 elements of stack memory)
- Efficient array rotation using trinity rotation algorithm
- Performance degrades on very large arrays (needs sqrt(n) memory for best performance)
- Not a drop-in library for most programming ecosystems (C source code only)
- Complex algorithmic implementation may be difficult to port or maintain
- Lacks comprehensive documentation beyond GitHub README