i have an Array List with Following values
ArrayList [Admin,Readonly,CSR,adminuser,user,customer]
when i used
Collections.sort(ArrayList)
i'm getting the Following Result
[Admin,CSR,Readonly,adminuser,customer,user]
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]
provide an help how will do the sorting irrespective of case in java, is there any other method available
Note: i will do an Automate test for checking the sorting order in the Web table
regards
prabu
You can do with custom Comparator.
Try this:
You will need to pass
Comparator
instance inCollections.sort()
method which comparesString
objects ignoring case.This'll do,
this is i have tried,
the following output i got,
then
Answer is simple - big letters have lower number in
ASCII
. So default comparing works fine.You can use your own comparator like this to sort irrespective of case (upper / lower case)