Sort List by alphabetical order

后端 未结 4 766
野的像风
野的像风 2020-12-09 10:05

I\'m trying to sort a list by alphabetical order and tried porting something i had in javascript to flutter. But it gives me an exception on String that it does not have the

4条回答
  •  囚心锁ツ
    2020-12-09 10:57

    < and > is usually a shortcut to a compareTo method.

    just use that method instead.

    data.sort((a, b) {
      return a['name'].toLowerCase().compareTo(b['name'].toLowerCase());
    });
    

提交回复
热议问题