I want the files to be ordered by their abs path name, but I want the lowercase to be sorted before the uppercase. Example: Let\'s say I got 4 files:
files2.
Try this simple implementation :
public static void main(String[] args) {
List list = new ArrayList();
list.add("a");
list.add("b");
list.add("A");
list.add("B");
System.out.println(list);
Collections.sort(list, new Comparator() {
@Override
public int compare(String o1, String o2) {
if (o1.toLowerCase().equals(o2.toLowerCase())) {
if (o1.toLowerCase().equals(o1)) {
return -1;
} else {
return 1;
}
} else {
return o1.toLowerCase().compareTo(o2.toLowerCase());
}
}
});
System.out.println(list);
}