Guido grants a Christmas wish:

sorted() becomes a regular function instead of a classmethod.
This commit is contained in:
Raymond Hettinger 2003-12-17 21:38:26 +00:00
parent b606b3d08a
commit a95e87a488

View file

@ -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}}