If you want to sort Objects in a list $C$ in Java, you use Collections.sort(myList) do it. This will apply the mergesort algorithm to any List of Objects. You only have to make sure that the compareTo(other) method is implemented for the objects you want to sort.
Now, if you read the JavaDoc of compareTo, it seems as if you would basically implement a relation "$\leq$" between objects in $C$. This relation has to be (according to my interpretation of the JavaDoc of compareTo):
- total: $\forall x, y \in C: x \leq y \lor y \leq x$
- antisymmetric: $\forall x,y \in C: x \leq y \land y \leq x \Rightarrow x = y$
- transitive: $\forall x,y,z \in C: x \leq y \land y \leq z \Rightarrow x \leq z$
It makes sense that the relation has to be total. A good example is $\mathbb{C}$ with the relation $\leq$ which should make clear, that totality is defenitely needed.
If you didn't have transitivity, you couldn't order the elements in a one-dimensional list. You also couldn't apply mergesort.
But why do you need antisymmetry?
Imagine a list $C$ of some humans and the relation "is at least as old as". This relation on $C$ is total, it is transitive, but if two people have the same age, they are not the same. But that isn't a problem for sorting, is it? So why do you need antisymmetry?
In mathematics, any two elements x and y of a set P that is partially ordered by a binary relation $\leq$ are comparable when either $x \leq y$ or $y \leq x$. If it is not the case that x and y are comparable, then they are called incomparable.
(Partial orders require reflexivity, antisymmetry, and transitivity, but not mutual comparability between every pair of elements.)
A totally ordered set is exactly a partially ordered set in which every pair of elements is comparable. A relation having the property of "totality" means that any pair of elements in the set of the relation are mutually comparable under the relation. Totality implies reflexivity, that is, $a \leq a$, thus a total order is also a partial order.
Mutual comparability between every pair of elements is required for "
compareTo(other)" to be well-defined for every pair of elements.Then you could have $\,x\leq y,\;\,y\leq x,\,$ and $\,x \neq y.\,$ Then you would have distinct $x, y$ such that $\,x \lt y\,$ and $\,y\lt x,\,$ which is impossible. For one thing, it thus fails to be total, because $\lt$ is the implicit strict total order, and with a strict total order, trichotomy must hold:
$\forall x, y \in \,\text{set},\;\;x\lt y\; \lor \;y \lt x\; \lor\; x = y$.