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

11
LINES

< > BotCompany Repo | #1006222 // makeReversedComparator - convert two-argument func to reversed Comparator

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

Libraryless. Click here for Pure Java version (9154L/51K).

static Comparator makeReversedComparator(O f) {
  ret new Comparator {
    public int compare(O a, O b) {
      ret (int) callF(f, b, a);
    }
  };
}

static <A> Comparator<A> makeReversedComparator(Comparator<A> c) {
  ret (a, b) -> c.compare(b, a);
}

Author comment

Began life as a copy of #1006220

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1006222
Snippet name: makeReversedComparator - convert two-argument func to reversed Comparator
Eternal ID of this version: #1006222/5
Text MD5: ac6cb840b61333dabde88492d8cee21a
Transpilation MD5: 0d03a84cd5ce9b13b8303d6453596158
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-07-25 16:07:06
Source code size: 263 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 560 / 641
Version history: 4 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1018649 - reverseComparator