smallest method

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

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

For example

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

returns [1, 2].

Implementation

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