summaryrefslogtreecommitdiffstats
path: root/Doc/howto/sorting.tex
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2005-11-20 00:24:18 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2005-11-20 00:24:18 (GMT)
commit4aef41ffe7bee84f3b6440f4d76099cd030d058b (patch)
tree826324864282c319e1333539f549206fe91d0112 /Doc/howto/sorting.tex
parent4737b2348b197d21deffbf12ff23488918e9b9d4 (diff)
downloadcpython-4aef41ffe7bee84f3b6440f4d76099cd030d058b.zip
cpython-4aef41ffe7bee84f3b6440f4d76099cd030d058b.tar.gz
cpython-4aef41ffe7bee84f3b6440f4d76099cd030d058b.tar.bz2
Remove import string and use string methods
Diffstat (limited to 'Doc/howto/sorting.tex')
-rw-r--r--Doc/howto/sorting.tex7
1 files changed, 3 insertions, 4 deletions
diff --git a/Doc/howto/sorting.tex b/Doc/howto/sorting.tex
index a849c66..37a7033 100644
--- a/Doc/howto/sorting.tex
+++ b/Doc/howto/sorting.tex
@@ -110,11 +110,10 @@ types, do the forward sort first, then use the \method{reverse()} method.
Here's a case-insensitive string comparison using a \keyword{lambda} function:
\begin{verbatim}
->>> import string
->>> a = string.split("This is a test string from Andrew.")
->>> a.sort(lambda x, y: cmp(string.lower(x), string.lower(y)))
+>>> a = "This is a test string from Andrew".split()
+>>> a.sort(lambda x, y: cmp(x.lower(), y.lower()))
>>> print a
-['a', 'Andrew.', 'from', 'is', 'string', 'test', 'This']
+['a', 'Andrew', 'from', 'is', 'string', 'test', 'This']
\end{verbatim}
This goes through the overhead of converting a word to lower case