sorted method

List<T> sorted(
  1. Iterable<T> iterable, {
  2. int? start,
  3. int? end,
  4. bool stable = false,
  5. bool growable = false,
})

Returns a sorted copy of the provided iterable.

If start (inclusive) and end (exclusive) are provided the sorting only happens within the specified range.

If stable is set to true, a stable merge-sort implementation is used instead of the standard quick-sort. This means that elements that compare equal stay in the order of the input.

By default a more efficient fixed-length list is returned, unless growable is set to true.

Implementation

List<T> sorted(Iterable<T> iterable,
    {int? start, int? end, bool stable = false, bool growable = false}) {
  final list = List.of(iterable, growable: growable);
  sort(list, start: start, end: end, stable: stable);
  return list;
}