Thursday, March 6, 2008

Java - case insensitive Array sort

java.util.Arrays#sort() is case sensitive.

String[] strArray = new String[]{"a","Z","b"}
Arrays.sort(strArray);
//the sorted array will be ={"Z","a","b"}

To get the case insensitive array sort use String.CASE_INSENSITIVE_ORDER

Arrays.sort(strArray, String.CASE_INSENSITIVE_ORDER); //the sorted array will be ={"a","b","Z"}

No comments:

Post a Comment

Search