sortedBy<K extends Comparable> method
Returns a new list sorted ascending by key.
Implementation
List<T> sortedBy<K extends Comparable<dynamic>>(K Function(T) key) {
final copy = [...this];
copy.sort((a, b) => key(a).compareTo(key(b)));
return copy;
}