sortedBy method
Returns this as sorted list using the comparator
function.
Example:
[3, 1, 5, 9, 7].sortedBy((a,b) => a.compareTo(b)); // [1, 3, 5, 7, 9]
Implementation
List<T> sortedBy(Comparator<T> comparator) {
ArgumentError.checkNotNull(comparator, 'comparator');
final list = toList();
list.sort(comparator);
return list;
}