Array List of String Sorting Method

后端 未结 6 544
小蘑菇
小蘑菇 2021-01-12 10:39

i have an Array List with Following values

ArrayList [Admin,Readonly,CSR,adminuser,user,customer]

when i used

Collections.s         


        
6条回答
  •  感情败类
    2021-01-12 10:55

    You can use your own comparator like this to sort irrespective of case (upper / lower case)

    Collections.sort(list, new Comparator() {
            @Override
            public int compare(String s1, String s2)
            {    
                return  s1.compareToIgnoreCase(s2);
            }
    });
    

提交回复
热议问题