public static void sortByNumberOfVersionsDesc ( List < ClasspathResource > resources ) { // sort by number of version occurrences Comparator < ClasspathResource > sortByNumberOfVersionsDesc = new Comparator < ClasspathResource > ( ) { @ Override public int compare ( ClasspathResource resource1 , ClasspathResource resource2 ) { return - 1 * new Integer ( resource1 . getResourceFileVersions ( ) . size ( ) ) . compareTo ( resource2 . getResourceFileVersions ( ) . size ( ) ) ; } } ; Collections . sort ( resources , sortByNumberOfVersionsDesc ) ; }
Takes a list of classpath resources and sorts them by the number of classpath versions .