How do python define the behavior of builtin sorted( ) when two elements are the same? Do they get an undeterministic order?
Asked
Active
Viewed 46 times
0
-
3Python's sort is stable. – vaultah Jul 28 '14 at 11:31
-
1This is referred to as "stability", and Timsort (the default sorting algorithm in CPython) *is* stable; two equal elements will have the same order in the output that they do in the input. See e.g. [here](http://stackoverflow.com/a/19587279/3001761). – jonrsharpe Jul 28 '14 at 11:34