public int compareTo(Object object) {
        // case of an object not instance of ComparableSet
        if (!(object instanceof ComparableSet)) {
            return -1;
        }

        // case of equality between this component and object
        if (this.equals(object)) {
            return 0;
        }

        // test if this component is smaller than the set by lectic order
        ComparableSet set = (ComparableSet) object;

        // computes index i of the first element in set minus this
        // if i doesn't exist, then this component is not smaller than the set by lectic order
        TreeSet<Comparable> setMinusThis = new TreeSet(set);
        setMinusThis.removeAll(this);
        if (setMinusThis.isEmpty()) {
            return 1;
        }

        Comparable i = setMinusThis.first();
        // compute this inter {1, ..., i-1}
        TreeSet setAiMinus1 = new TreeSet();
        for (Object c : this) {
            if (i.compareTo(c) > 0) {
                setAiMinus1.add(c);
            }
        }
        // compute set inter {1, ..., i-1}
        TreeSet setBiMinus1 = new TreeSet();
        for (Object c : set) {
            if (i.compareTo(c) > 0) {
                setBiMinus1.add(c);
            }
        }
        // if setAiminus1 and setBiminus1 are equal then this component is smaller than B by lectic order
        if  (setAiMinus1.equals(setBiMinus1)) {
            return -1;
        } else {
            return 1;
        }
    }