串排序方法数组列表 [英] Array List of String Sorting Method
本文介绍了串排序方法数组列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下值的数组列表
ArrayList [Admin,Readonly,CSR,adminuser,user,customer]
当我用
Collections.sort(ArrayList)
我得到以下结果。
i'm getting the Following Result
[Admin,CSR,Readonly,adminuser,customer,user]
以Java文档上述结果是正确的,但我的期望是(排序不分的情况下(大/小写)
as per the Java doc the above results are correct, but my Expectation is (sorting irrespective of case (upper / lower case)
[Admin,adminuser,CSR,customer,Readonly,user]
提供帮助,怎么会做排序的情况下,不论在Java中,有没有其他任何可用的方法
provide an help how will do the sorting irrespective of case in java, is there any other method available
请注意:我会做一个自动化测试用于检查在Web表格中的排列顺序
Note: i will do an Automate test for checking the sorting order in the Web table
关于
prabu
推荐答案
这会做,
Collections.sort(yourList, String.CASE_INSENSITIVE_ORDER);
这是我已经尽力了,
ArrayList<String> myList=new ArrayList<String>();
Collections.addAll(myList,"Admin","Readonly","CSR","adminuser","user","customer");
System.out.println(myList);
Collections.sort(myList, String.CASE_INSENSITIVE_ORDER);
System.out.println(myList);
以下输出我得到了,
the following output i got,
[Admin, Readonly, CSR, adminuser, user, customer]
[Admin, adminuser, CSR, customer, Readonly, user]
这篇关于串排序方法数组列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文