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

13
LINES

< > BotCompany Repo | #1002452 - sortedByField

JavaX fragment (include)

1  
static <A> L<A> sortedByField(Collection<A> c, final S field) {
2  
  L<A> l = new ArrayList(c);
3  
  sort(l, new Comparator<A>() {
4  
    public int compare(A a, A b) {
5  
      ret cmp(getOpt(a, field), getOpt(b, field));
6  
    }
7  
  });
8  
  ret l;
9  
}
10  
11  
static <A> L<A> mapMethodLike sortedByField(S field, Collection<A> c) {
12  
  ret sortedByField(c, field);
13  
}

Author comment

Began life as a copy of #1002319

download  show line numbers  debug dex   

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

No comments. add comment

Snippet ID: #1002452
Snippet name: sortedByField
Eternal ID of this version: #1002452/2
Text MD5: 9f6d74be958833b82b6b1bfbd2ba4987
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-05-11 13:43:18
Source code size: 351 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 454 / 418
Version history: 1 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1002452 & http://1002452.tinybrain.de