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

13
LINES

< > BotCompany Repo | #1032236 // sortedBy - synonym of sortByCalculatedField

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

Libraryless. Click here for Pure Java version (3140L/17K).

static <A, B> L<A> lambdaMapLike sortedBy(IF1<A, B> f, Iterable<A> c) {
  ret sortedBy(c, f);
}

static <A, B> L<A> sortedBy(Iterable<A> c, IF1<A, B> f) {
  L<A> l = cloneList(c);
  sort(l, new Comparator<A>() {
    public int compare(A a, A b) {
      ret stdcompare(f.get(a), f.get(b));
    }
  });
  ret l;
}

Author comment

Began life as a copy of #1017753

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1032236
Snippet name: sortedBy - synonym of sortByCalculatedField
Eternal ID of this version: #1032236/1
Text MD5: b78a1ce5b1827ba3a6a09d89805c6631
Transpilation MD5: 6be7460fbbade636d840c269d8321266
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-08-21 02:18:34
Source code size: 323 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 85 / 136
Referenced in: [show references]