I'm trying to reproduce the issue mentioned in this post: Comparison method violates its general contract
What I do is making a parent class A, which has it's own compareTo() function, then I made a class B inherits from class A, and overrides the compareTo() like:
public int compareTo(Object o) { return super.compareTo(o);}
And another class C also inherits from class A, and overrides the compareTo() as:
public int compareTo(Object o) { return -super.compareTo(o);}
So I made a list of bunch of class B/C objects, and use Collections.sort() to sort them, however I didn't see the Exception mentioned in previous post, the sort function runs well, but it gives me a weird order.
Could someone help me here? Thanks.