diff options
author | Raymond Hettinger <python@rcn.com> | 2003-12-17 21:38:26 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2003-12-17 21:38:26 (GMT) |
commit | a95e87a48822ac459fddb2e81c3f7583a70a56e3 (patch) | |
tree | e43bcd8a83e24cf37dea6b8cb6c119a93a372149 /Doc/tut | |
parent | b606b3d08af3cc15e880650bab3c773131c4ec66 (diff) | |
download | cpython-a95e87a48822ac459fddb2e81c3f7583a70a56e3.zip cpython-a95e87a48822ac459fddb2e81c3f7583a70a56e3.tar.gz cpython-a95e87a48822ac459fddb2e81c3f7583a70a56e3.tar.bz2 |
Guido grants a Christmas wish:
sorted() becomes a regular function instead of a classmethod.
Diffstat (limited to 'Doc/tut')
-rw-r--r-- | Doc/tut/tut.tex | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Doc/tut/tut.tex b/Doc/tut/tut.tex index b03f683..cbec92c 100644 --- a/Doc/tut/tut.tex +++ b/Doc/tut/tut.tex @@ -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}} |