pub fn min_by<T>(
iter: impl IntoIterator<Item = T>,
n: usize,
cmp: impl FnMut(&T, &T) -> Ordering
) -> Vec<T>
Returns the n
smallest items from an iterator with a comparator function.
This function is stable, i.e. it preserves the order of equal elements.
Panics if n > len
.
let max = out::iter::min_by(-10_i32..10, 3, |a, b| b.cmp(a));
assert_eq!(max, [7, 8, 9]);