]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Various edits
authorAndrew M. Kuchling <amk@amk.ca>
Thu, 13 Nov 2003 21:33:26 +0000 (21:33 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Thu, 13 Nov 2003 21:33:26 +0000 (21:33 +0000)
Doc/whatsnew/whatsnew24.tex

index 646a35c016490088b742fd6c4e1ee2fadde9bcec..4e2a9d83bcc50441deeb19ebd239b30e1b194f0d 100644 (file)
@@ -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}