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
5c22476c
Commit
5c22476c
authored
Jun 01, 2019
by
Tim Hoffmann
Committed by
Raymond Hettinger
May 31, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve docstring of list.sort (GH-8516)
parent
396e0a8d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
Objects/clinic/listobject.c.h
Objects/clinic/listobject.c.h
+10
-2
Objects/listobject.c
Objects/listobject.c
+10
-2
No files found.
Objects/clinic/listobject.c.h
View file @
5c22476c
...
...
@@ -156,7 +156,15 @@ PyDoc_STRVAR(list_sort__doc__,
"sort($self, /, *, key=None, reverse=False)
\n
"
"--
\n
"
"
\n
"
"Stable sort *IN PLACE*."
);
"Sort the list in ascending order and return None.
\n
"
"
\n
"
"The sort is in-place (i.e. the list itself is modified) and stable (i.e. the
\n
"
"order of two equal elements is maintained).
\n
"
"
\n
"
"If a key function is given, apply it once to each list item and sort them,
\n
"
"ascending or descending, according to their function values.
\n
"
"
\n
"
"The reverse flag can be set to sort in descending order."
);
#define LIST_SORT_METHODDEF \
{"sort", (PyCFunction)(void(*)(void))list_sort, METH_FASTCALL|METH_KEYWORDS, list_sort__doc__},
...
...
@@ -359,4 +367,4 @@ list___reversed__(PyListObject *self, PyObject *Py_UNUSED(ignored))
{
return
list___reversed___impl
(
self
);
}
/*[clinic end generated code: output=
d1d5078edb7d3cf4
input=a9049054013a1b77]*/
/*[clinic end generated code: output=
73718c0c33798c62
input=a9049054013a1b77]*/
Objects/listobject.c
View file @
5c22476c
...
...
@@ -2197,12 +2197,20 @@ list.sort
key as keyfunc: object = None
reverse: bool(accept={int}) = False
Stable sort *IN PLACE*.
Sort the list in ascending order and return None.
The sort is in-place (i.e. the list itself is modified) and stable (i.e. the
order of two equal elements is maintained).
If a key function is given, apply it once to each list item and sort them,
ascending or descending, according to their function values.
The reverse flag can be set to sort in descending order.
[clinic start generated code]*/
static
PyObject
*
list_sort_impl
(
PyListObject
*
self
,
PyObject
*
keyfunc
,
int
reverse
)
/*[clinic end generated code: output=57b9f9c5e23fbe42 input=
b0fcf743982c5b9
0]*/
/*[clinic end generated code: output=57b9f9c5e23fbe42 input=
cb56cd179a71306
0]*/
{
MergeState
ms
;
Py_ssize_t
nremaining
;
...
...
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