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
119d026b
Commit
119d026b
authored
Apr 29, 2012
by
Brett Cannon
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
acf85cd1
b77b5c30
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
Doc/howto/sorting.rst
Doc/howto/sorting.rst
+3
-3
No files found.
Doc/howto/sorting.rst
View file @
119d026b
...
...
@@ -42,7 +42,7 @@ lists. In contrast, the :func:`sorted` function accepts any iterable.
Key Functions
=============
Both :meth:`list.sort` and :func:`sorted` have *key* parameter to specify a
Both :meth:`list.sort` and :func:`sorted` have
a
*key* parameter to specify a
function to be called on each list element prior to making comparisons.
For example, here's a case-insensitive string comparison:
...
...
@@ -89,7 +89,7 @@ Operator Module Functions
The key-function patterns shown above are very common, so Python provides
convenience functions to make accessor functions easier and faster. The
:mod:`operator` module has :func:`~operator.itemgetter`,
:func:`~operator.attrgetter`, and a
n
:func:`~operator.methodcaller` function.
:func:`~operator.attrgetter`, and a :func:`~operator.methodcaller` function.
Using those functions, the above examples become simpler and faster:
...
...
@@ -114,7 +114,7 @@ Ascending and Descending
========================
Both :meth:`list.sort` and :func:`sorted` accept a *reverse* parameter with a
boolean value. This is us
ing
to flag descending sorts. For example, to get the
boolean value. This is us
ed
to flag descending sorts. For example, to get the
student data in reverse *age* order:
>>> sorted(student_tuples, key=itemgetter(2), reverse=True)
...
...
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