Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

11
LINES

< > BotCompany Repo | #1015308 // sortFilesByDateDesc

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (4782L/27K).

// newest first
static L<File> sortFilesByDateDesc(Collection<File> files) {
  ret sortedByComparator(files, new Comparator<File>{
    AutoMap<File, Long> dates = new AutoMap<File, Long>(lambda1 lastModified); // cache to ensure comparator is sane
    
    public int compare(File b, File a) {
      long x = dates.get(a), y = dates.get(b);
      return x < y ? -1 : x == y ? 0 : 1;
    }
  });
}

Author comment

Began life as a copy of #1003182

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1015308
Snippet name: sortFilesByDateDesc
Eternal ID of this version: #1015308/10
Text MD5: 100c5514396ddf1cfe77f97fa620802f
Transpilation MD5: e0b1445013f9c855d76fde248227201e
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-29 02:16:45
Source code size: 406 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 418 / 539
Version history: 9 change(s)
Referenced in: [show references]