sort method

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

Sorts this list according to the order specified by the compare function. If compare is not provided, it will use the natural ordering of the type T.

Implementation

L<T> sort([int Function(T a, T b)? compare]) {
  // Explicitly sorts MapEntry (since MapEntry is not Comparable).
  if ((compare == null) && (T == MapEntry))
    compare = (T a, T b) => (a as MapEntry).compareKeyAndValue(b as MapEntry);

  return LFlat<T>.unsafe(unlock..sort(compare ?? compareObject));
}