orderBy method

List<T> orderBy(
  1. Sort<T>? sort
)

Sorts the iterable using the given sort configuration. If sort is null, returns the original iterable as a list. Returns a new sorted list (non-mutating).

Implementation

List<T> orderBy(Sort<T>? sort) {
  if (sort == null) return toList();
  final list = toList();
  list.sort((a, b) => sort.compare(a, b));
  return list;
}