Function out::max_by_key
source · Expand description
Get the n
largest items with a key extraction function.
This method is stable, i.e. it preserves the order of equal elements.
Examples
let mut v = [-5_i32, 4, 1, -3, 2];
let max = out::max_by_key(&mut v, 3, |a| a.abs());
assert_eq!(max, [-3, 4, -5]);