Set<String> set = resultsMap.keySet();
ArrayList<String> allPaths = new ArrayList<String>(set);
Collections.sort(allPaths);
for (String path : allPaths) {
DirectoryResults dirResults = new DirectoryResults(path);
List<FileResults> allResults = resultsMap.get(path);
Collections.sort(allResults, new Comparator<FileResults>() {
public int compare(FileResults o1, FileResults o2) {
return o1.getPath().compareTo(o2.getPath());
}
});
for (FileResults child : allResults) {
dirResults.addChild(child);
}
AtomicInteger cnt = fileCountMap.get(path);
dirResults.setNumberOfFilesInThisDirectory(cnt != null ? cnt.get() : 0);
addToParentResults(reportResults, dirResults);
}
}