summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2003-12-17 21:38:26 (GMT)
committerRaymond Hettinger <python@rcn.com>2003-12-17 21:38:26 (GMT)
commita95e87a48822ac459fddb2e81c3f7583a70a56e3 (patch)
treee43bcd8a83e24cf37dea6b8cb6c119a93a372149
parentb606b3d08af3cc15e880650bab3c773131c4ec66 (diff)
downloadcpython-a95e87a48822ac459fddb2e81c3f7583a70a56e3.zip
cpython-a95e87a48822ac459fddb2e81c3f7583a70a56e3.tar.gz
cpython-a95e87a48822ac459fddb2e81c3f7583a70a56e3.tar.bz2
Guido grants a Christmas wish:
sorted() becomes a regular function instead of a classmethod.
-rw-r--r--Doc/tut/tut.tex14
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}}