sortedCopyBy method
Returns a copy of this list sorted by the value returned by sortKey
for
each element.
This method is guaranteed to calculate sortKey
only once for each
element.
Example:
var list = [-12, 3, 10];
var sorted = list.sortedCopyBy((e) => e.toString().length);
// list is still [-12, 3, 10]. sorted is [3, 10, -12].
Implementation
List<E> sortedCopyBy(Comparable<dynamic> Function(E) sortKey) {
return List<E>.of(this)..sortBy(sortKey);
}