sortedByCompare<K> method

List<T> sortedByCompare<K>(
  1. K keyOf(
    1. T element
    ),
  2. Comparator<K> compare
)

Creates a sorted list of the elements of the iterable.

The elements are ordered by the compare Comparator of the property keyOf of the element.

Implementation

List<T> sortedByCompare<K>(
    K Function(T element) keyOf, Comparator<K> compare) {
  var elements = [...this];
  mergeSortBy<T, K>(elements, keyOf, compare);
  return elements;
}