Stable sort algorithms sort equal elements in the same order that they appear in the input.
>>> stable_sort([(10, 'a'), (8, 'b'), (3, 'c'), (8, 'd')])
[(3, 'c'), (8, 'b'), (8, 'd'), (10, 'a')])
Bibliography
“Sorting Algorithm.” 2022. Wikipedia, June. https://en.wikipedia.org/w/index.php?title=Sorting_algorithm&oldid=1095879356.