This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Tutorial section on dictionary keys recommends sort instead of sorted
Type: Stage: commit review
Components: Documentation Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, georg.brandl, kent, terry.reedy
Priority: low Keywords: easy

Created on 2010-03-30 19:18 by kent, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
dict.patch kent, 2010-03-30 19:18 Use sorted instead of sort
Messages (5)
msg101953 - (view) Author: Kent Engström (kent) Date: 2010-03-30 19:18
The 2.[567] documentation recommends the use of the sort() method
to get a sorted list of dictionary keys. If would be less confusing
to new users if we recommended the sorted() functions instead.

The corresponding piece of Python 3 documentation already uses
the sorted() function.
msg102151 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-04-02 09:40
I'm not sure about this; what is the advantage?  If you already have a list, calling .sort() on it is more efficient since it doesn't have to create a new list.
msg102158 - (view) Author: Kent Engström (kent) Date: 2010-04-02 11:24
Is should have mentioned that we're discussion a section
of the tutorial concerned with dictionaries. It is not a
section on lists, sequences or sorting as such.

My colleague, who asked me for help after getting confused
by sort, was trying to loop over the keys in the dictionary
in sorted order.  In that context, sorted is superior to sort.
msg112759 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-08-04 04:56
This amounts to backporting the 3.x change.
msg118783 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-10-15 15:31
Fixed in r85529.
History
Date User Action Args
2022-04-11 14:56:59adminsetgithub: 52514
2010-10-15 15:31:16georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg118783
2010-08-04 04:56:50terry.reedysetpriority: normal -> low

assignee: georg.brandl -> docs@python
versions: - Python 2.6, Python 2.5
keywords: + easy, - patch
nosy: + terry.reedy, docs@python

messages: + msg112759
stage: commit review
2010-04-02 11:24:06kentsetmessages: + msg102158
2010-04-02 09:40:45georg.brandlsetmessages: + msg102151
2010-03-30 19:20:46kentsettitle: Tutorial secion on dictionary keys recommends sort instead of sorted -> Tutorial section on dictionary keys recommends sort instead of sorted
2010-03-30 19:18:50kentcreate