[][src]Function out::max_unstable_by

pub fn max_unstable_by<T>(
    v: &mut [T],
    n: usize,
    cmp: impl FnMut(&T, &T) -> Ordering
) -> &mut [T]

Get the n largest items with a comparator function.

This method is not stable, i.e. it may not preserve the order of equal elements. This method should be faster than max_unstable_by in most cases, and can be used with no_std.

Panics

Panics if n > len.

Examples

let mut v = [-5, 4, 1, -3, 2];
let min = out::max_unstable_by(&mut v, 3, |a, b| b.cmp(a));
assert_eq!(min, [1, -3, -5]);