Libraryless. Click here for Pure Java version (111L/1K).
1 | scope generalizedCIComparator |
2 | |
3 | // non-strings must be Comparable to each other |
4 | // probably this is not that useful after all |
5 | |
6 | static simplyCached #C generalizedCIComparator() {
|
7 | ret new C; |
8 | } |
9 | |
10 | final sclass #C implements Comparator<O> {
|
11 | public int compare(O o1, O o2) {
|
12 | if (o1 cast S) |
13 | if (o2 cast S) |
14 | ret betterCIComparator().compare(o1, o2); |
15 | else |
16 | ret -1; |
17 | else |
18 | if (o2 instanceof S) |
19 | ret 1; |
20 | else |
21 | ret cmp(o1, o2); |
22 | } |
23 | } |
Began life as a copy of #1014136
download show line numbers debug dex old transpilations
Travelled to 5 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1031513 |
| Snippet name: | generalizedCIComparator (allows non-strings which are compared normally and put in after all the strings) |
| Eternal ID of this version: | #1031513/3 |
| Text MD5: | 142b58aec63cbf7fd7d7b1ad6a461a7c |
| Transpilation MD5: | 2e58ae4d12d02662ec9306bdce2b0133 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2021-06-17 06:38:26 |
| Source code size: | 498 bytes / 23 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 369 / 500 |
| Version history: | 2 change(s) |
| Referenced in: | [show references] |