[−][src]Function sorting_rs::bubble_sort::bubble_sort
pub fn bubble_sort<T: PartialOrd>(input: &mut [T])
Sorts an input slice in-place using
Bubble sort.
All kinds of slices can be sorted as long as they implement
PartialOrd
.
Examples
let mut slice = vec![3,2,1,4]; sorting_rs::bubble_sort(&mut slice); assert_eq!(slice, &[1,2,3,4]);
let mut strings = vec!["rustc", "cargo", "rustup"]; sorting_rs::bubble_sort(&mut strings); assert_eq!(strings, &["cargo", "rustc", "rustup"]);