[][src]Function out::iter::max_unstable_by_key

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

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

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

Panics

Panics if n > len.

Examples

let max = out::iter::max_unstable_by_key(-10_i32..10, 3, |a| a.abs());
assert_eq!(max, [9, -9, -10]);