[−][src]Function sorting_rs::cycle_sort::cycle_sort
pub fn cycle_sort<T: PartialOrd + Copy>(input: &mut [T])
Sorts a slice in-place using
Cycle sort.
All kinds of slices can be sorted as long as they implement
PartialOrd
.
This kind of sort is pretty good in case you need as low writes as possible, for example, using SSD or NAND memory.
Examples
let mut vec = vec![56, 32, 78, 16]; sorting_rs::cycle_sort(&mut vec); assert_eq!(vec, &[16, 32, 56, 78]);
let mut strings = vec!["rustc", "cargo", "rustup"]; sorting_rs::cycle_sort(&mut strings); assert_eq!(strings, &["cargo", "rustc", "rustup"]);