mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Streamline mention of sorted()
This commit is contained in:
parent
c561a9adac
commit
dec0f21efc
1 changed files with 4 additions and 4 deletions
|
|
@ -625,10 +625,10 @@ order to remind you of that fact, it does not return the sorted list. This way,
|
|||
you won't be fooled into accidentally overwriting a list when you need a sorted
|
||||
copy but also need to keep the unsorted version around.
|
||||
|
||||
In Python 2.4 a new built-in function -- :func:`sorted` -- has been added.
|
||||
This function creates a new list from a provided iterable, sorts it and returns
|
||||
it. For example, here's how to iterate over the keys of a dictionary in sorted
|
||||
order::
|
||||
If you want to return a new list, use the built-in :func:`sorted` function
|
||||
instead. This function creates a new list from a provided iterable, sorts
|
||||
it and returns it. For example, here's how to iterate over the keys of a
|
||||
dictionary in sorted order::
|
||||
|
||||
for key in sorted(mydict):
|
||||
... # do whatever with mydict[key]...
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue