pub fn sort_by_key<T, B, F>(v: &mut [T], f: F)
Expand description
Sorts a slice using f
to extract a key to compare elements by.
This sort is in-place, unstable, and O(n log n)
worst-case.
The implementation is based on Orson Peters’ pattern-defeating quicksort.
§Examples
extern crate pdqsort;
let mut v = [-5i32, 4, 1, -3, 2];
pdqsort::sort_by_key(&mut v, |k| k.abs());
assert!(v == [1, 2, -3, 4, -5]);