static class ComparableList extends ArrayList implements Comparable { *() {} *(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; } }