Java tutorial
//package com.java2s; import java.io.File; import java.util.Arrays; import java.util.Comparator; public class Main { public static File[] dirListByDescendingDate(File[] files) { Arrays.sort(files, new Comparator() { public int compare(final Object o1, final Object o2) { return new Long(((File) o2).lastModified()).compareTo(new Long(((File) o1).lastModified())); } }); return files; } }