sorted method

List<E> sorted([
  1. int compare(
    1. E a,
    2. E b
    )?
])

Return a new array that is sorted by the compare function

Implementation

List<E> sorted([int Function(E a, E b)? compare]) {
  final items = toList();
  items.sort(compare);
  return items;
}