summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>2003-11-13 21:33:26 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>2003-11-13 21:33:26 (GMT)
commit981a91857515d66c4faf60c0f63a9de0d770d217 (patch)
tree990eaa08b4f2256f01695c678383c401a90ea909 /Doc
parentb845ef056ac33e2d65556cb7924d2084f89d2e0c (diff)
downloadcpython-981a91857515d66c4faf60c0f63a9de0d770d217.zip
cpython-981a91857515d66c4faf60c0f63a9de0d770d217.tar.gz
cpython-981a91857515d66c4faf60c0f63a9de0d770d217.tar.bz2
Various edits
Diffstat (limited to 'Doc')
-rw-r--r--Doc/whatsnew/whatsnew24.tex16
1 files changed, 9 insertions, 7 deletions
diff --git a/Doc/whatsnew/whatsnew24.tex b/Doc/whatsnew/whatsnew24.tex
index 646a35c..4e2a9d8 100644
--- a/Doc/whatsnew/whatsnew24.tex
+++ b/Doc/whatsnew/whatsnew24.tex
@@ -104,8 +104,8 @@ using a \var{key} parameter. Using \var{key} results in calling the
\method{lower()} method once for each element in the list while using
\var{cmp} will call the method twice for each comparison.
-Note, for simple key functions and comparison functions, it is often
-possible to avoid the \keyword{lambda} expression by using an unbound
+For simple key functions and comparison functions, it is often
+possible to avoid a \keyword{lambda} expression by using an unbound
method instead. For example, the above case-insensitive sort is best
coded as:
@@ -120,10 +120,11 @@ The \var{reverse} parameter should have a Boolean value. If the value is
of \code{L.sort(lambda x,y: cmp(y.score, x.score))}, you can now write:
\code{L.sort(key = lambda x: x.score, reverse=True)}.
-The results of sorting are now guaranteed to be stable. This means that
-two entries with equal keys will be returned in the same order as
-they were input.
-
+The results of sorting are now guaranteed to be stable. This means
+that two entries with equal keys will be returned in the same order as
+they were input. For example, you can sort a list of people by name,
+and then sort the list by age, resulting in a list sorted by age where
+people with the same age are in name-sorted order.
\item The list type gained a \method{sorted(iterable)} method that works
like the in-place \method{sort()} method but has been made suitable for
@@ -143,6 +144,7 @@ use in expressions. The differences are:
>>> list.sorted('Monte Python') # any iterable may be an input
[' ', 'M', 'P', 'e', 'h', 'n', 'n', 'o', 'o', 't', 't', 'y']
>>> colormap = dict(red=1, blue=2, green=3, black=4, yellow=5)
+>>> # Lists the contents of the dict sorted by key values
>>> for k, v in list.sorted(colormap.iteritems()):
... print k, v
...
@@ -293,6 +295,6 @@ changes to your code:
The author would like to thank the following people for offering
suggestions, corrections and assistance with various drafts of this
-article: .
+article: Raymond Hettinger.
\end{document}