@Override
    public int compareTo(Spring other) {
        if (other == null) {
            throw new IllegalArgumentException("The argument may not be null.");
        }

        int thisHigherIndex = this.getMassWithHigherIndex().getIndex(graph);
        int otherHigherIndex = other.getMassWithHigherIndex().getIndex(graph);

        if (thisHigherIndex != otherHigherIndex) {
            return thisHigherIndex - otherHigherIndex;
        }

        int thisLowerIndex = this.getMassWithLowerIndex().getIndex(graph);
        int otherLowerIndex = other.getMassWithLowerIndex().getIndex(graph);

        return thisLowerIndex - otherLowerIndex;
    }