Commit a95e87a4 authored by Raymond Hettinger's avatar Raymond Hettinger

Guido grants a Christmas wish:

  sorted() becomes a regular function instead of a classmethod.
parent b606b3d0
...@@ -2211,6 +2211,20 @@ function. ...@@ -2211,6 +2211,20 @@ function.
1 1
\end{verbatim} \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}} \section{More on Conditions \label{conditions}}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment