0

How do python define the behavior of builtin sorted( ) when two elements are the same? Do they get an undeterministic order?

Hello lad
  • 17,344
  • 46
  • 127
  • 200
  • 3
    Python's sort is stable. – vaultah Jul 28 '14 at 11:31
  • 1
    This 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

0 Answers0