Stable sort algorithms sort equal elements in the same order that they appear in the input.

(“Sorting Algorithm” 2022)

stable_sort([(10, 'a'), (8, 'b'), (3, 'c'), (8, 'd')])
> [(3, 'c'), (8, 'b'), (8, 'd'), (10, 'a')])

References