@Override
    public int compare(Object key1, Object key2) {
        int result = checkNull(key1, key2);
        if (result != not_null) {
            return result;
        }

        List a1 = (List) key1;
        List a2 = (List) key2;
        if (a1.size() != a2.size()) {
            return a1.size() > a2.size() ? 1 : -1;
        }
        if (a1.size() == 0) {
            return 0;
        }
        // For array, the length may not be fixed, so extend comparators on demand
        for (int i = comparators.size(); i < a1.size(); i++) {
            // For struct, all elements may not be of same type, so create comparator for each entry.
            comparators.add(i, WritableComparatorFactory.get(a1.get(i), nullSafe, nullOrdering));
        }
        result = 0;
        for (int i = 0; i < a1.size(); i++) {
            result = comparators.get(i).compare(a1.get(i), a2.get(i));
            if (result != 0) {
                return result;
            }
        }
        return result;
    }
A WritableComparator to compare STRUCT or ARRAY objects.
ql/src/java/org/apache/hadoop/hive/ql/exec/HiveStructComparator.java