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

13
LINES

< > BotCompany Repo | #1008426 // ComparableList

JavaX fragment (include)

1  
static class ComparableList extends ArrayList implements Comparable<ComparableList> {
2  
  *() {}
3  
  *(L l) { super(l); }
4  
  
5  
  public int compareTo(ComparableList l) {
6  
    int n1 = l(this), n2 = l(l), n = min(n1, n2);
7  
    for i to n: {
8  
      int x = stdcompare(get(i), l.get(i));
9  
      if (x != 0) ret x;
10  
    }
11  
    ret n1 > n2 ? 1 : n1 == n2 ? 0 : -1;
12  
  }
13  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1008426
Snippet name: ComparableList
Eternal ID of this version: #1008426/1
Text MD5: a85e99b55c59ad8467214e441ea87a03
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-05-15 15:14:53
Source code size: 365 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 455 / 1061
Referenced in: [show references]