[][src]Function out::iter::max_unstable_by

pub fn max_unstable_by<T>(
    iter: impl IntoIterator<Item = T>,
    n: usize,
    cmp: impl FnMut(&T, &T) -> Ordering
) -> Vec<T>

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

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

Panics

Panics if n > len.

Examples

let min = out::iter::max_unstable_by(-10..10, 3, |a, b| b.cmp(a));
assert_eq!(min, [-8, -9, -10]);