public int comparePrimarilyByIndexTo(HostResource other) {
        if (this.spec.membership().isPresent() && other.spec.membership().isPresent())
            return Integer.compare(this.spec.membership().get().index(), other.spec.membership().get().index());
        else
            return this.getHostname().compareTo(other.getHostname());
    }
Compares by the index of the primary membership, if both hosts are members in at least one cluster at this time.
Compare by hostname otherwise.
config-model/src/main/java/com/yahoo/vespa/model/HostResource.java