I just found this statement: "One can greatly increase the performance of compareTo by comparing first on items which are most likely to differ". Is it true? And if it is, why?
Consider a class with several properties. For comparing instances, you need to compare some of their properties. If all properties except one are equal, the amount of comparisons you need to do depends on the order of the property comparisons: if you happen to compare the differing properties first, you got the result with one comparison. But if you compare the differing properties last, you had to do n comparisons to get the same result.
As @Kdeveloper noted, the performance difference may not be noticeable unless you do lots of similar comparisons in batches. But the other benefit is IMHO logical ordering: this makes you think about the logical relationship between class properties. And overall, since this is a nondisruptive optimization (i.e. it does not make the code more difficult to read and maintain), I think it is worth doing it most of the time.