Guest User

Untitled

a guest
Jul 16th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. def lastModifiedDate(app: ApplicationInfo) = (new File(app.sourceDir)).lastModified()
  2. val sortedApps = repository.all.sortWith(lastModifiedDate(_) > lastModifiedDate(_))
  3.  
  4. VS
  5.  
  6. private List<ApplicationInfo> getApplicationsSortedByDate(List<ApplicationInfo> apps) {
  7.  
  8. Comparator<ApplicationInfo> dateComparator = new Comparator<ApplicationInfo>() {
  9. public int compare(ApplicationInfo appInfo1, ApplicationInfo appInfo2) {
  10. long date1 = new File(appInfo1.sourceDir).lastModified();
  11. long date2 = new File(appInfo2.sourceDir).lastModified();
  12. return new Long(date1).compareTo(date2);
  13. }
  14. };
  15.  
  16. Collections.sort(apps, dateComparator);
  17. return apps;
  18. }
Add Comment
Please, Sign In to add comment