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

前端 未结 12 1793
刺人心
刺人心 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:43

    The string compare algorithm compare each character at a time. 1 sorts before 2. It doesn't matter that it is followed by a 1 or a 2.

    So 100 would sort before 2. If you don't want this behavior, you need a compare algorithm that handles this case.

提交回复
热议问题