Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
ccae479e
Commit
ccae479e
authored
Nov 09, 2014
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue 22830: Clarify docs for functools.cmp_to_key().
parent
fb136d19
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
Doc/library/functools.rst
Doc/library/functools.rst
+7
-4
No files found.
Doc/library/functools.rst
View file @
ccae479e
...
...
@@ -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)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment