bpo-35020: Link to sorting examples from list.sort()#9931
bpo-35020: Link to sorting examples from list.sort()#9931rhettinger merged 2 commits intopython:masterfrom
Conversation
|
|
||
| The `Timsort <https://en.wikipedia.org/wiki/Timsort>`_ algorithm used in Python | ||
| does multiple sorts efficiently because it can take advantage of any ordering | ||
| already present in a dataset. |
There was a problem hiding this comment.
I expect this comment is too late, but the old text here is senseless: it can only exploit order in the field currently being sorted. There's no general reason to imagine that sorting on a field has any effect on the degree of order seen by any other field. That said, correlation can be expected across some kinds of fields (e.g., "age" and "income" fields), but that's wholly data-dependent.
There was a problem hiding this comment.
Thanks, since the PR is merged would you like me to make a new PR for this? I think it can be below as I can understand from your comment but feedback welcome
The `Timsort <https://en.wikipedia.org/wiki/Timsort>`_ algorithm used in Python
does multiple sorts efficiently because it can take advantage of any ordering
already present in a dataset with respect to the field being used for sorting.There was a problem hiding this comment.
Nope! There's no reason at all to believe that the algorithm can do "multiple sorts efficiently" in general. It is true that the algorithm can take major advantage of pre-existing order, but that has nothing in general to do with multiple sorts. So if this needs to be said at all(*), it doesn't belong in the "multiple sorting" section at all.
(*) About "at all": Python the language doesn't guarantee its sort method can take any advantage of pre-existing order. That was a primary goal of "timsort", but remains an implementation detail rather than a language feature.
There was a problem hiding this comment.
Thanks, I think this is inappropriate for the section and if at all it needs to be present then it can be moved somewhere else as you have mentioned though there are no notes section in this page like some of the other pages where this can be added. It also has to be updated that the current behavior in the doc is a CPython implementation detail. Any suggestions @rhettinger ?
Link to Sorting examples from
list.sort()likesorted. This doesn't really need a NEWS entry. I have added the issue number in title as a reference since the PR was created with the doc suggestion.Ref : https://bugs.python.org/issue35010#msg327901
https://bugs.python.org/issue35010