Skip to content

bpo-35020: Link to sorting examples from list.sort()#9931

Merged
rhettinger merged 2 commits intopython:masterfrom
tirkarthi:bpo35010-docs
Oct 20, 2018
Merged

bpo-35020: Link to sorting examples from list.sort()#9931
rhettinger merged 2 commits intopython:masterfrom
tirkarthi:bpo35010-docs

Conversation

@tirkarthi
Copy link
Copy Markdown
Member

@tirkarthi tirkarthi commented Oct 17, 2018

Link to Sorting examples from list.sort() like sorted. 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

@bedevere-bot bedevere-bot added docs Documentation in the Doc dir awaiting review labels Oct 17, 2018
@tirkarthi tirkarthi changed the title bpo-35010: Link to sorting examples from list.sort() bpo-35020: Link to sorting examples from list.sort() Oct 18, 2018
@rhettinger rhettinger self-assigned this Oct 20, 2018
@rhettinger rhettinger merged commit 890a4b9 into python:master Oct 20, 2018
Comment thread Doc/howto/sorting.rst

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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

@tirkarthi tirkarthi Oct 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants