diff options
author | Brett Cannon <brett@python.org> | 2014-11-10 01:22:53 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2014-11-10 01:22:53 (GMT) |
commit | 223bc2fe1653d21fc00ff8ebf1379cefadba808a (patch) | |
tree | c95b3fffee29cfbd1f35959a4977d52eef6d19e6 | |
parent | b7299ddbc7b504220e67ee026e5587a346c0ce3a (diff) | |
parent | 87fc6f5c8e416f6b7ba068d792742cfd142ab673 (diff) | |
download | cpython-223bc2fe1653d21fc00ff8ebf1379cefadba808a.zip cpython-223bc2fe1653d21fc00ff8ebf1379cefadba808a.tar.gz cpython-223bc2fe1653d21fc00ff8ebf1379cefadba808a.tar.bz2 |
Merge with default
-rw-r--r-- | Doc/library/functools.rst | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Doc/library/functools.rst b/Doc/library/functools.rst index 7fd7d58..d87fa58 100644 --- a/Doc/library/functools.rst +++ b/Doc/library/functools.rst @@ -21,8 +21,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 from Python 2 which supported the use of @@ -31,13 +31,14 @@ 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 indicating 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 :ref:`sortinghowto`. + .. versionadded:: 3.2 |