How can I sort this ArrayList the way that I want?

前端 未结 12 1789
刺人心
刺人心 2020-12-04 18:17

Here is a simple sorting program of an ArrayList:

ArrayList list = new ArrayList();

list.add(\"1_Update\");
list.add(\"11_Add\")         


        
12条回答
  •  感动是毒
    2020-12-04 18:54

    To have Collection.sort() sort arbitrarily you can use

    Collections.sort(List list, Comparator c)  
    

    Then simply implement a Comparator that splits the string and sorts first based on the number and then on the rest or however you want it to sort.

提交回复
热议问题