How can I sort a list of strings in Dart?

后端 未结 5 1993
萌比男神i
萌比男神i 2020-12-03 06:18

I see in the API docs there is a sort() method on List, but I\'m not clear what it needs for a parameter. The current need is for a very simple st

5条回答
  •  独厮守ぢ
    2020-12-03 07:05

    After today, you should just be able to do list.sort() . The sort method's argument is now optional, and it defaults to a function that calls compareTo on the elements themselves. Since String is Comparable, it should Just Work now.

提交回复
热议问题