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

13
LINES

< > BotCompany Repo | #1008426 // ComparableList

JavaX fragment (include)

static class ComparableList extends ArrayList implements Comparable<ComparableList> {
  *() {}
  *(L l) { super(l); }
  
  public int compareTo(ComparableList l) {
    int n1 = l(this), n2 = l(l), n = min(n1, n2);
    for i to n: {
      int x = stdcompare(get(i), l.get(i));
      if (x != 0) ret x;
    }
    ret n1 > n2 ? 1 : n1 == n2 ? 0 : -1;
  }
}

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: 451 / 1055
Referenced in: [show references]