Algorithm for sorting by equivalence relation

38 Views Asked by At

I hope the thread title isn't too strange, but I don't know better. My question seems a quite simple one.

Having a set of objects I'm interested in the subsets that are pairwise equal.

Example: A set of numbers {7, 3, 8, 4, 3, 2, 7, 5, 2}

I'm interested in having them sorted in a way that the "equal ones" are grouped.

For example like {7, 7, 8, 4, 3, 3, 2, 2, 5}.

An alg would be to sort them by size. But I don't need them ordered that way.

Is there a way to do it cheaper than n * log n?