[][src]Function sorting_rs::ksort::ksort

pub fn ksort<T: PartialOrd + Clone + Copy>(input: &mut [T])

Sorts a slice in-place using K-sort

This sorting algorithm is in fact a modification of quick sort which should be faster than quicksort for arrays with less than 7 million elements This algorithm is generally compared to heapsort and quicksort, it doesn't need to construct the heap and generally wins in benchmarks because of this.

Examples

let mut vec = vec![5, 2, 7, 3, 9];
sorting_rs::ksort(&mut vec);
debug_assert_eq!(vec, &[2, 3, 5, 7, 9]);
let mut strings = vec!["rustc", "cargo", "rustup"];
sorting_rs::ksort(&mut strings);
assert_eq!(strings, &["cargo", "rustc", "rustup"]);