I am having a bit of brain fail and I can't remeber the name of the following problem (so I can find some literature around it...).
Given a sequence of values, sort it in a way that equal elements are compacted in runs (contiguous subsequences of identical elements).
For instance:
$$ \{1, 2, 4, 2, 1, 3\} \rightarrow \{ 2, 2, 4, 3, 1, 1 \} $$
The runs are not otherwise sorted -- only equality comparison is required, not ordering; and they're compacted (there should not be two different runs containing equal elements).