Let\'s have a class Person. Person has a name and height.
Equals and hashCode() takes into account only name. Person is comparable (or we implement co
It is strongly recommended, but not strictly required that (x.compareTo(y)==0) == (x.equals(y)) [1]
So it's fine that you compare with a different criteria than the used on equals granted that you document it.
However it would be better if your compare by the same criteria and if needed provide a custom comparator which works on the new criteria ( height in the case of Person )