sorted method Null safety

List<T> sorted(
  1. [Comparator<T>? compare]
)

Creates a sorted list of the elements of the iterable.

If the compare function is not supplied, the sorting uses the natural Comparable ordering of the elements.

Implementation

List<T> sorted([Comparator<T>? compare]) => [...this]..sort(compare);