[][src]Function out::iter::min_unstable_by

pub fn min_unstable_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 sort is unstable (i.e. may reorder equal elements) and typically faster than min_by.

Panics

Panics if n > len.

Examples

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