Function dmsort::sort_by_key
[−]
[src]
pub fn sort_by_key<T, K, F>(slice: &mut [T], key: F) where K: Ord, F: FnMut(&T) -> K
Sorts the elements using the given key function.
Examples
let mut numbers : Vec<i32> = vec!(0, 1, 6, 7, 2, 3, 4, 5); dmsort::sort_by_key(&mut numbers, |x| -x); assert_eq!(numbers, vec!(7, 6, 5, 4, 3, 2, 1, 0));