largest method

List<E> largest(
  1. int count, {
  2. Comparator<E>? comparator,
})

Returns a list of the count largest elements of this Iterable. The elements need to be Comparable, unless a custom comparator is provided.

For example

[3, 1, 2].largest(2)

returns [3, 2].

Implementation

List<E> largest(int count, {Comparator<E>? comparator}) =>
    (comparator ?? naturalCompare).largest(this, count);