sorted method

List<T> sorted({
  1. bool isDesc = false,
})

Get sorted list

Example:

list.sorted(true) // create new list with ascending order

Implementation

List<T> sorted({bool isDesc = false}) {
  final List<T> copy = List<T>.of(this);
  copy.sort();
  return isDesc ? copy.reversed.toList() : copy;
}