[][src]Function out::iter::min_unstable_by_key

pub fn min_unstable_by_key<T, K: Ord>(
    iter: impl IntoIterator<Item = T>,
    n: usize,
    f: impl FnMut(&T) -> K
) -> Vec<T>

Returns the n smallest items from an iterator with a key extraction function.

This sort is unstable (i.e. may reorder equal elements) and typically faster than min_by_key.

Panics

Panics if n > len.

Examples

let min = out::iter::min_unstable_by_key(-10_i32..10, 3, |a| a.abs());
assert_eq!(min, [1, -1, 0]);