See Also: IComparable Members
This interface should be implemented by all classes that wish to define a natural order of their instances. Java.Util.Collections.sort(java.util.List<T>) and java.util.Arrays#sort can then be used to automatically sort lists of classes that implement this interface.
The order rule must be both transitive (if x.compareTo(y) and y.compareTo(z) , then x.compareTo(z) must hold) and invertible (the sign of the result of x.compareTo(y) must be equal to the negation of the sign of the result of y.compareTo(x) for all combinations of x and y).
In addition, it is recommended (but not required) that if and only if the result of x.compareTo(y) is zero, then the result of x.equals(y) should be true.