AlphabeticDescending implements FileSorter, Comparator<File> { @Override public List<File> sort(List<File> list) { Collections.sort(list, this); return list; }  @Override List<File> sort(List<File> list); @Override int compare(File o1, File o2);  }
@Test public void testSort() throws Exception { AlphabeticDescending sorter = new AlphabeticDescending(); List<File> files = createFiles(10); files = sorter.sort(files); log("Sorted", files); String lastFilename = String.format("%1$s-%2$03d%3$s", AlphabeticDescendingTest.class.getSimpleName(), 1, ".xml"); String firstFilename = String.format("%1$s-%2$03d%3$s", AlphabeticDescendingTest.class.getSimpleName(), 10, ".xml"); File firstFile = files.get(0); File lastFile = files.get(9); assertEquals(firstFilename, firstFile.getName()); assertEquals(lastFilename, lastFile.getName()); }