I want to get a list of files in a directory, but I want to sort it such that the oldest files are first. My solution was to call File.listFiles and just resort the list ba
private static List sortByLastModified(String dirPath) { List files = listFilesRec(dirPath); Collections.sort(files, new Comparator() { public int compare(File o1, File o2) { return Long.compare(o1.lastModified(), o2.lastModified()); } }); return files; }