Edit:
In java8:
Arrays.sort(files, (a, b) -> Long.compare(a.lastModified(), b.lastModified()));
link
I found some interesting code,very close to what you need, have a look at it(Just a quick on the run implementation of Comparator):
File f = new File("/home/myfiles");
File [] files = f.listFiles();
Arrays.sort( files, new Comparator()
{
public int compare(Object o1, Object o2) {
if (((File)o1).lastModified() > ((File)o2).lastModified()) {
return -1;
} else if (((File)o1).lastModified() < ((File)o2).lastModified()) {
return +1;
} else {
return 0;
}
}
});
Also you can have a look at this post, see how the guy solved the problem: Best way to list files in Java, sorted by Date Modified?