static public <T> Comparator<T[]> arrayComparator(Comparator<T> cmp) {        
        return (a, b) -> {
            if (a == null) {
                return b == null ? 0 : 1;
            } else if (b == null) {
                return -1;
            }
            int n = a.length;
            if (n != b.length) {
                return Integer.compare(n, b.length);
            }      
            for (int i = 0; i < n; i++) {
                int c = cmp.compare(a[i], b[i]);
                if (c != 0) {
                    return c;
                }
            }        
            return 0;
        };
    }