pub fn sort_by_key<T, S, B, F>(slice: S, f: F) -> Permutation where
    B: Ord,
    S: AsRef<[T]>,
    F: FnMut(&T) -> B, 
Expand description

Return the permutation that would sort a given slice by a key function.

This is the same as permutation::sort() except that it allows you to specify the key function simliar to std::slice.sort_by_key()

Examples

let mut vec = vec![2, 4, 6, 8, 10, 11];
let permutation = permutation::sort_by_key(&vec, |a| a % 3);
let permuted = permutation.apply_slice(&vec);
vec.sort_by_key(|a| a % 3);
assert_eq!(vec, permuted);