List.sort's one parameter can now be optional #5870
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
closed-duplicate
Closed in favor of an existing report
type-enhancement
A request for a change that isn't a bug
I see the Comparable.compare is a static method you can give to sort:
main() {
var fruits = <String>['bananas', 'apples', 'oranges'];
fruits.sort(Comparable.compare);
print(fruits);
}
It would be nice to make sort's parameter optional, and use Comparable.compare if a parameter is not provided:
sort([Comparator comparator]) // use Comparable.compare if no comparator is given
Then we can so this:
fruits.sort();
Which is a common case.
The text was updated successfully, but these errors were encountered: