Nexus Sort
A cognitive, multi-strategy sorting framework in Rust, designed for high performance by intelligently choosing the best sorting strategy for your data. This library was designed and built as a collaboration between a human user and a large language model (Google's Gemini).
Core Concept
Instead of a "one size fits all" approach, NexusSort analyzes the input data and selects the optimal algorithm from its arsenal:
- For integers, it uses its Cognitive Engine to choose between a hyper-optimized stable sort (
Timsort) or unstable sort (Introsort). For random data, it defaults to a Radix Sort for maximum performance. - For floats, it uses a specialized
f32sorter that can leverage a bit-level Radix Sort, yielding massive performance gains over traditional comparison sorts.
Performance: Proof of Victory
Benchmarks were conducted against the Rust 1.xx.x standard library's sorting functions. The results demonstrate significant performance gains.
Integer Sorting (Random i32 Data)
NexusSort (using its Radix path) vs. std::sort_unstable.
| Input Size | NexusSort (µs) | std::sort_unstable (µs) |
Performance Gain |
|---|---|---|---|
| 1,000 | ~12.5 µs | ~24.1 µs | ~93% Faster |
| 10,000 | ~172.3 µs | ~215.2 µs | ~25% Faster |
Float Sorting (Random f32 Data)
NexusSort (using its Radix path) vs. std::sort (stable).
| Input Size | NexusSort (µs) | std::sort (µs) |
Performance Gain |
|---|---|---|---|
| 1,000 | ~16.3 µs | ~50.8 µs | ~212% Faster |
| 10,000 | ~174.4 µs | ~1129.7 µs | ~547% Faster |
Usage
Add this to your Cargo.toml:
[]
= "1.0.1"
And use it in your code:
use ;
// Sorting integers
let mut numbers = vec!;
nexus_sort;
// Sorting floats
let mut floats = vec!;
nexus_sort_f32;
License
This project is licensed under the MIT License.