[][src]Function sorting_rs::bingo_sort::bingo_sort

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

Sorts a slice in-place using Bingo sort. All kinds of slices can be sorted as long as they implement PartialOrd.

This algorithm aims to be more effective than selection sort in cases there are many duplicate values.

Examples

let mut vec = vec![56, 32, 78, 16];
sorting_rs::bingo_sort(&mut vec);
assert_eq!(vec, &[16, 32, 56, 78]);
let mut strings = vec!["rustc", "cargo", "rustup"];
sorting_rs::bingo_sort(&mut strings);
assert_eq!(strings, &["cargo", "rustc", "rustup"]);