summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2014-11-10 01:10:17 (GMT)
committerRaymond Hettinger <python@rcn.com>2014-11-10 01:10:17 (GMT)
commitccae479e2de19a042a75a1c1e1cdca7453de86f6 (patch)
tree65c3dc998a38d844302266df96d22501dcbf445e /Doc
parentfb136d19ff57d42cad9a7177ba8fdad3ef1577c6 (diff)
downloadcpython-ccae479e2de19a042a75a1c1e1cdca7453de86f6.zip
cpython-ccae479e2de19a042a75a1c1e1cdca7453de86f6.tar.gz
cpython-ccae479e2de19a042a75a1c1e1cdca7453de86f6.tar.bz2
Issue 22830: Clarify docs for functools.cmp_to_key().
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/functools.rst11
1 files changed, 7 insertions, 4 deletions
diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst
index 9336f79..086b0b5 100644
--- a/Doc/library/functools.rst
+++ b/Doc/library/functools.rst
@@ -22,8 +22,8 @@ The :mod:`functools` module defines the following functions:
.. function:: cmp_to_key(func)
- Transform an old-style comparison function to a key function. Used with
- tools that accept key functions (such as :func:`sorted`, :func:`min`,
+ Transform an old-style comparison function to a :term:`key function`. Used
+ with tools that accept key functions (such as :func:`sorted`, :func:`min`,
:func:`max`, :func:`heapq.nlargest`, :func:`heapq.nsmallest`,
:func:`itertools.groupby`). This function is primarily used as a transition
tool for programs being converted to Python 3 where comparison functions are
@@ -32,13 +32,16 @@ The :mod:`functools` module defines the following functions:
A comparison function is any callable that accept two arguments, compares them,
and returns a negative number for less-than, zero for equality, or a positive
number for greater-than. A key function is a callable that accepts one
- argument and returns another value that indicates the position in the desired
- collation sequence.
+ argument and returns another value to be used as the sort key.
Example::
sorted(iterable, key=cmp_to_key(locale.strcoll)) # locale-aware sort order
+ For sorting examples and a brief sorting tutorial, see `Sorting HowTo
+ <https://wiki.python.org/moin/HowTo/Sorting/>`_\.
+
+
.. versionadded:: 2.7
.. function:: total_ordering(cls)