Skip to content

Instantly share code, notes, and snippets.

@jbrechtel
Created December 4, 2010 03:26
Show Gist options
  • Select an option

  • Save jbrechtel/727882 to your computer and use it in GitHub Desktop.

Select an option

Save jbrechtel/727882 to your computer and use it in GitHub Desktop.
def lastModifiedDate(app: ApplicationInfo) = (new File(app.sourceDir)).lastModified()
val sortedApps = repository.all.sortWith(lastModifiedDate(_) > lastModifiedDate(_))
VS
private List<ApplicationInfo> getApplicationsSortedByDate(List<ApplicationInfo> apps) {
Comparator<ApplicationInfo> dateComparator = new Comparator<ApplicationInfo>() {
public int compare(ApplicationInfo appInfo1, ApplicationInfo appInfo2) {
long date1 = new File(appInfo1.sourceDir).lastModified();
long date2 = new File(appInfo2.sourceDir).lastModified();
return new Long(date1).compareTo(date2);
}
};
Collections.sort(apps, dateComparator);
return apps;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment