Function dmsort::sort_by [] [src]

pub fn sort_by<T, F>(slice: &mut [T], compare: F) where F: FnMut(&T, &T) -> Ordering

Sorts the elements using the given compare function.

Examples

let mut numbers : Vec<i32> = vec!(0, 1, 6, 7, 2, 3, 4, 5);
dmsort::sort_by(&mut numbers, |a, b| b.cmp(a));
assert_eq!(numbers, vec!(7, 6, 5, 4, 3, 2, 1, 0));