How can i sort my arraylist alphabetical

后端 未结 2 1193
忘掉有多难
忘掉有多难 2021-01-28 20:48

I want to sort my arraylist alphabetical but I don\'t get it...maybe you can help me. I dont know why but i cant work with collections.sort...what am i coding wrong? thanks a l

2条回答
  •  情歌与酒
    2021-01-28 21:17

    Use Collections.sort

    Collections.sort(listOfStrings, String.CASE_INSENSITIVE_ORDER);
    

    See the following for details:

    String.CASE_INSENSITIVE_ORDER

    Collections.sort

    You can also create a custom Comparator, instead of using String.CASE_INSENSITIVE_ORDER

提交回复
热议问题