int (@NotNull File f1, @NotNull File f2) { // "Program Files" is preferable over "Program Files (x86)" int compareParents = f1.getParentFile().getName().compareTo(f2.getParentFile().getName()); if (compareParents != 0) { return -compareParents; // greater is better => reversing } // probably some unrecognized format of Git directory naming => just compare lexicographically String name1 = StringUtil.toLowerCase(f1.getName()); String name2 = StringUtil.toLowerCase(f2.getName()); return name1.compareTo(name2); }