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

13
LINES

< > BotCompany Repo | #1015687 // sortedByFields

JavaX fragment (include)

static <A> L<A> sortedByFields(Collection<A> c, final S... fields) {
  L<A> l = new ArrayList(c);
  sort(l, new Comparator<A>() {
    public int compare(A a, A b) {
      for (S field : fields) {
        int x = cmp(getOpt(a, field), getOpt(b, field));
        if (x != 0) ret x;
      }
      ret 0;
    }
  });
  ret l;
}

Author comment

Began life as a copy of #1002452

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1015687
Snippet name: sortedByFields
Eternal ID of this version: #1015687/3
Text MD5: 68ef0cb368f23261c02f87f9d6b375b9
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-21 16:27:39
Source code size: 335 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 406 / 437
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)