public int compare(TaskDetails task1, TaskDetails task2) {
int diff = STRING_COMPARATOR.compare(task1.getPath().getName(), task2.getPath().getName());
if (diff != 0) {
return diff;
}
Path parent1 = task1.getPath().getParent();
Path parent2 = task2.getPath().getParent();
if (parent1 == null && parent2 != null) {
return -1;
}
if (parent1 != null && parent2 == null) {
return 1;