[Python-checkins] cpython (merge 3.5 -> default): merge

raymond.hettinger python-checkins at python.org
Tue Apr 26 04:11:34 EDT 2016


https://hg.python.org/cpython/rev/ac165e566573
changeset:   101153:ac165e566573
parent:      101149:f09306f9fa6f
parent:      101152:ae1e55102449
user:        Raymond Hettinger <python at rcn.com>
date:        Tue Apr 26 01:11:28 2016 -0700
summary:
  merge

files:
  Doc/howto/sorting.rst |  6 +++++-
  1 files changed, 5 insertions(+), 1 deletions(-)


diff --git a/Doc/howto/sorting.rst b/Doc/howto/sorting.rst
--- a/Doc/howto/sorting.rst
+++ b/Doc/howto/sorting.rst
@@ -262,7 +262,11 @@
   twice:
 
     >>> data = [('red', 1), ('blue', 1), ('red', 2), ('blue', 2)]
-    >>> assert sorted(data, reverse=True) == list(reversed(sorted(reversed(data))))
+    >>> standard_way = sorted(data, key=itemgetter(0), reverse=True)
+    >>> double_reversed = list(reversed(sorted(reversed(data), key=itemgetter(0))))
+    >>> assert standard_way == double_reversed
+    >>> standard_way
+    [('red', 1), ('red', 2), ('blue', 1), ('blue', 2)]
 
 * The sort routines are guaranteed to use :meth:`__lt__` when making comparisons
   between two objects. So, it is easy to add a standard sort order to a class by

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list