[−][src]Function buldak::bubble::sort_by
pub fn sort_by<T, F>(array: &mut [T], compare: F) where
T: Ord,
F: Fn(&T, &T) -> Ordering,
It takes a comparator function to determine the order, and sorts it using a bubble sort algorithm.
use buldak::bubble; let mut nums = [1, 4, 2, 3, 5, 111, 234, 21, 13]; bubble::sort_by(&mut nums, |l, r| l.cmp(r)); assert_eq!(nums, [1, 2, 3, 4, 5, 13, 21, 111, 234]);