topElements method

List<num> topElements(
  1. int k
)

Returns the k greatest elements of given set.

Implementation

List<num> topElements (int k) {
  var copy = toList(growable: false);
  copy.sort();
  return copy.sublist(length-k);
}