I understand that as a general rule of dumb an objects comparator method should be consistent with the objects equals method. Now what if I want to sort on some common attributes that a list may have. And this attribute does not determine whether an object is equal or not. In other words is it any way possible for me to use a comparator where compare(o1,o2) == 0 and o1.equals(o2) == false?
posted 13 years ago
My understanding is that you can sort with Comparitor not consistant with equals, if the underlying collection is not using equals in a way inconsistant with what the search is trying to do (as is the case in the example they give involving search). But I've never tried it, nor have I fully researched it. [ June 17, 2002: Message edited by: John Dale ]