You may try to look for Collections.sort and then try like this:-
Collections.sort(caps, String.CASE_INSENSITIVE_ORDER);
Something like this:-
private static Comparator<String> ALPHA_ORDER = new Comparator<String>() {
public int compare(String str1, String str2) {
int x = String.CASE_INSENSITIVE_ORDER.compare(str1, str2);
if (x== 0) {
x= str1.compareTo(str2);
}
return x;
}
};
Collections.sort(list, ALPHA_ORDER);
EDIT:-
For sorting alphabetically in a string try like this:-
Collator col = Collator.getInstance(new Locale("en", "EN"));
String s = "AbaC";
String[] s1= s.split("");
Arrays.sort(s1, col);
String sorted = "";
for (int i = 0; i < s1.length; i++)
{
sorted += s1[i];
}
System.out.println(sorted);