sort method

void sort(
  1. List<T> list, {
  2. int? start,
  3. int? end,
  4. bool stable = false,
})

Sorts the provided list in-place.

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.

Implementation

void sort(List<T> list, {int? start, int? end, bool stable = false}) {
  start ??= 0;
  end ??= list.length;
  if (stable) {
    mergeSort<T>(list, start: start, end: end, compare: this);
  } else {
    list.sortRange(start, end, this);
  }
}