sortOrdered method

IList<T> sortOrdered([
  1. int compare(
    1. T a,
    2. T b
    )?
])

Sorts this list according to the order specified by the compare function.

This is similar to sort, but uses a merge sort algorithm.

On contrary to sort, sortOrdered is stable, meaning distinct objects that compare as equal end up in the same order as they started in.

IList<String> numbers = ['one', 'two', 'three', 'four'].lock;
numbers = numbers.sort((a, b) => a.length.compareTo(b.length));
print(numbers);  // [one, two, four, three]

Implementation

IList<T> sortOrdered([int Function(T a, T b)? compare]) =>
    IList._unsafe(_l.sortOrdered(compare), config: config);