I do not understand the underlying problem that tries to solve the stable sorting algorithm.
Arrays.sort(Object[])
Javadoc states:
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
But if elements are equal, they are not distringuishable from each other! If you swap two equal elements, this should not affect anything. This is the definition of equality.
So, why do we need stability at all?
UPDATE: My question is about Collections.sort(List<T>)
/ Objects.sort(Object[])
methods, not Collections.sort(List<T>, Comparator<T>)
, Objects.sort(Comparator<T>)
. The latter ones are bit different. But there is still no need for stability for them: if you want predictable compound sorts, then you create appropriate compound comparators.