Force stable sort for grouping