summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2008-01-30 20:15:17 (GMT)
committerRaymond Hettinger <python@rcn.com>2008-01-30 20:15:17 (GMT)
commit70b64fce96e894dfa8af5afd1f8b3fe863ba16e0 (patch)
tree15d549753edea1f11c0a3990ea0419426220c445 /Doc
parent4f066126d616d35aa8c0911a915ad64a09aaf16e (diff)
downloadcpython-70b64fce96e894dfa8af5afd1f8b3fe863ba16e0.zip
cpython-70b64fce96e894dfa8af5afd1f8b3fe863ba16e0.tar.gz
cpython-70b64fce96e894dfa8af5afd1f8b3fe863ba16e0.tar.bz2
Issue #1771: Remove cmp parameter from list.sort() and builtin.sorted().
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/functions.rst15
-rw-r--r--Doc/library/stdtypes.rst14
2 files changed, 3 insertions, 26 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index 0126831..afa9198 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -959,31 +959,20 @@ available. They are listed here in alphabetical order.
``a[start:stop:step]`` or ``a[start:stop, i]``.
-.. function:: sorted(iterable[, cmp[, key[, reverse]]])
+.. function:: sorted(iterable[, key[, reverse]])
Return a new sorted list from the items in *iterable*.
- The optional arguments *cmp*, *key*, and *reverse* have the same meaning as
+ The optional arguments *key* and *reverse* have the same meaning as
those for the :meth:`list.sort` method (described in section
:ref:`typesseq-mutable`).
- *cmp* specifies a custom comparison function of two arguments (iterable
- elements) which should return a negative, zero or positive number depending on
- whether the first argument is considered smaller than, equal to, or larger than
- the second argument: ``cmp=lambda x,y: cmp(x.lower(), y.lower())``. The default
- value is ``None``.
-
*key* specifies a function of one argument that is used to extract a comparison
key from each list element: ``key=str.lower``. The default value is ``None``.
*reverse* is a boolean value. If set to ``True``, then the list elements are
sorted as if each comparison were reversed.
- In general, the *key* and *reverse* conversion processes are much faster than
- specifying an equivalent *cmp* function. This is because *cmp* is called
- multiple times for each list element while *key* and *reverse* touch each
- element only once.
-
.. function:: staticmethod(function)
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 22ca0f0..6a2be28 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -1266,8 +1266,7 @@ Note that while lists allow their items to be of any type, bytearray object
| ``s.reverse()`` | reverses the items of *s* in | \(6) |
| | place | |
+------------------------------+--------------------------------+---------------------+
-| ``s.sort([cmp[, key[, | sort the items of *s* in place | (6), (7) |
-| reverse]]])`` | | |
+| ``s.sort([key[, reverse]])`` | sort the items of *s* in place | (6), (7) |
+------------------------------+--------------------------------+---------------------+
.. index::
@@ -1321,23 +1320,12 @@ Notes:
The :meth:`sort` method takes optional arguments for controlling the
comparisons.
- *cmp* specifies a custom comparison function of two arguments (list items) which
- should return a negative, zero or positive number depending on whether the first
- argument is considered smaller than, equal to, or larger than the second
- argument: ``cmp=lambda x,y: cmp(x.lower(), y.lower())``. The default value
- is ``None``.
-
*key* specifies a function of one argument that is used to extract a comparison
key from each list element: ``key=str.lower``. The default value is ``None``.
*reverse* is a boolean value. If set to ``True``, then the list elements are
sorted as if each comparison were reversed.
- In general, the *key* and *reverse* conversion processes are much faster than
- specifying an equivalent *cmp* function. This is because *cmp* is called
- multiple times for each list element while *key* and *reverse* touch each
- element only once.
-
Starting with Python 2.3, the :meth:`sort` method is guaranteed to be stable. A
sort is stable if it guarantees not to change the relative order of elements
that compare equal --- this is helpful for sorting in multiple passes (for