@Override
    public int compareTo(FieldValue fieldValue) {
        int comp = super.compareTo(fieldValue);

        if (comp != 0) {
            return comp;
        }
        //types are equal, this must be of this type
        MapFieldValue<K,V> rhs = (MapFieldValue<K,V>) fieldValue;
        if (size() < rhs.size()) {
            return -1;
        } else if (size() > rhs.size()) {
            return 1;
        }
        Map.Entry<K,V> [] entries = entrySet().toArray(new Map.Entry[size()]);
        Map.Entry<K,V> [] rhsEntries = rhs.entrySet().toArray(new Map.Entry[rhs.size()]);
        Arrays.sort(entries, Comparator.comparing(Map.Entry<K,V>::getKey));
        Arrays.sort(rhsEntries, Comparator.comparing(Map.Entry<K,V>::getKey));
        for (int i = 0; i < entries.length; i++) {
            comp = entries[i].getKey().compareTo(rhsEntries[i].getKey());
            if (comp != 0) return comp;
            comp = entries[i].getValue().compareTo(rhsEntries[i].getValue());
            if (comp != 0) return comp;
        }

        return 0;
    }
Checks if another object is equal to this set.

@param o the object to check for equality with
@return true if o is an instance of WeightedSet and the two encapsulated Maps are equal, false otherwise
document/src/main/java/com/yahoo/document/datatypes/MapFieldValue.java