Skip to content

Commit

Permalink
Various edits
Browse files Browse the repository at this point in the history
  • Loading branch information
akuchling committed Nov 13, 2003
1 parent b845ef0 commit 981a918
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Doc/whatsnew/whatsnew24.tex
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ \section{Other Language Changes}
\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:

Expand All @@ -120,10 +120,11 @@ \section{Other Language Changes}
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
Expand All @@ -143,6 +144,7 @@ \section{Other Language Changes}
>>> 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
...
Expand Down Expand Up @@ -293,6 +295,6 @@ \section{Acknowledgements \label{acks}}

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}

0 comments on commit 981a918

Please sign in to comment.