sortBy<TKey extends Comparable> method

void sortBy<TKey extends Comparable>(
  1. TKey selector(
    1. TValue
    ), [
  2. bool ascending = true
])

Sorts this List by comparing the keys returned by the selector.

Implementation

void sortBy<TKey extends Comparable>(TKey Function(TValue) selector,
    [bool ascending = true]) {
  sort((a, b) => ascending
      ? Comparable.compare(selector(a), selector(b))
      : Comparable.compare(selector(b), selector(a)));
}