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

19
LINES

< > BotCompany Repo | #1006221 // sortedDesc - takes a Collection<A> and an optional func(A, A) -> int

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

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

1  
static <A> L<A> sortedDesc(Collection<A> c, O comparator) {
2  
  L<A> l = cloneList(c);
3  
  sort(l, makeReversedComparator(comparator));
4  
  ret l;
5  
}
6  
7  
static <A> L<A> sortedDesc(Collection<A> c, Comparator<A> comparator) {
8  
  L<A> l = cloneList(c);
9  
  sort(l, makeReversedComparator(comparator));
10  
  ret l;
11  
}
12  
13  
// TODO: should use a reverse comparator to keep sort stable
14  
static <A> L<A> sortedDesc(Collection<A> c) {
15  
  L<A> l = cloneList(c);
16  
  sort(l);
17  
  Collections.reverse(l);
18  
  ret l;
19  
}

Author comment

Began life as a copy of #1003400

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: #1006221
Snippet name: sortedDesc - takes a Collection<A> and an optional func(A, A) -> int
Eternal ID of this version: #1006221/3
Text MD5: 9e915a64114377d6506e1d2ec6b138fe
Transpilation MD5: 31af186979d7d4e3ad5c4ebb8ecd2c99
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:52
Source code size: 497 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 575 / 638
Version history: 2 change(s)
Referenced in: [show references]