You can use a TreeMap with a custom, case-insensitive Comparator
(that uses String.compareToIgnoreCase())
For example:
Map map =
new TreeMap(CaseInsensitiveComparator.INSTANCE);
class CaseInsensitiveComparator implements Comparator {
public static final CaseInsensitiveComparator INSTANCE =
new CaseInsensitiveComparator();
public int compare(String first, String second) {
// some null checks
return first.compareToIgnoreCase(second);
}
}
Update: it seems that String
has already defined this Comparator
as a constant.