mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Guido grants a Christmas wish:
sorted() becomes a regular function instead of a classmethod.
This commit is contained in:
parent
b606b3d08a
commit
a95e87a488
1 changed files with 14 additions and 0 deletions
|
@ -2211,6 +2211,20 @@ function.
|
|||
1
|
||||
\end{verbatim}
|
||||
|
||||
To loop over a sequence in sorted order, use the \function{sorted()}
|
||||
function which returns a new sorted list while leaving the source
|
||||
unaltered.
|
||||
|
||||
\begin{verbatim}
|
||||
>>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
|
||||
>>> for f in sorted(set(basket)):
|
||||
... print f
|
||||
...
|
||||
apple
|
||||
banana
|
||||
orange
|
||||
pear
|
||||
\end{verbatim}
|
||||
|
||||
\section{More on Conditions \label{conditions}}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue