Problem Statement
Is Python's built-in sort stable and which algorithm does it use?
Explanation
list.sort and sorted use TimSort, which is stable. Equal keys keep their original relative order.
Stability enables multi-key sorts by sorting on a secondary key first, then on the primary key.
Code Solution
SolutionRead Only
data=[('bob',3),('bob',1)]
print(sorted(data, key=lambda t:t[0]))