Skip to content

Commit 7d19a8a

Browse files
committed
docs
1 parent 137c47f commit 7d19a8a

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

Doc/library/stdtypes.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,7 @@ application).
13941394
:ref:`mutable <typesseq-mutable>` sequence operations. Lists also provide the
13951395
following additional method:
13961396

1397-
.. method:: list.sort(*, key=None, reverse=False)
1397+
.. method:: list.sort(*, key=None, keylist=None, reverse=False)
13981398

13991399
This method sorts the list in place, using only ``<`` comparisons
14001400
between items. Exceptions are not suppressed - if any comparison operations
@@ -1414,6 +1414,9 @@ application).
14141414
The :func:`functools.cmp_to_key` utility is available to convert a 2.x
14151415
style *cmp* function to a *key* function.
14161416

1417+
Alternative to key function is supplying a list to *keylist* argument,
1418+
which will determine sort order and will be modified in place.
1419+
14171420
*reverse* is a boolean value. If set to ``True``, then the list elements
14181421
are sorted as if each comparison were reversed.
14191422

@@ -1436,6 +1439,11 @@ application).
14361439
list appear empty for the duration, and raises :exc:`ValueError` if it can
14371440
detect that the list has been mutated during a sort.
14381441

1442+
The same applies to *keylist* argument.
1443+
1444+
.. versionchanged:: 3.15
1445+
1446+
Added *keylist* argument.
14391447

14401448
.. _typesseq-tuple:
14411449

Objects/listobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2935,7 +2935,7 @@ order of two equal elements is maintained).
29352935
If a key function is given, apply it once to each list item and sort them,
29362936
ascending or descending, according to their function values.
29372937
2938-
Alternative to key function is supplying list to keylist argument,
2938+
Alternative to key function is supplying a list to keylist argument,
29392939
which will determine sort order and will be modified in place.
29402940
29412941
The reverse flag can be set to sort in descending order.

Python/bltinmodule.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2644,7 +2644,8 @@ sorted as builtin_sorted
26442644
Return a new list containing all items from the iterable in ascending order.
26452645
26462646
A custom key function can be supplied to customize the sort order.
2647-
Alternatively, keylist argument accepts a list on which sort order is based.
2647+
Alternative to key function is supplying a list to keylist argument,
2648+
which will determine sort order and will be modified in place.
26482649
The reverse flag can be set to request the result in descending order.
26492650
Both key and keylist can not be used at the same time.
26502651
[end disabled clinic input]*/
@@ -2656,7 +2657,8 @@ PyDoc_STRVAR(builtin_sorted__doc__,
26562657
"Return a new list containing all items from the iterable in ascending order.\n"
26572658
"\n"
26582659
"A custom key function can be supplied to customize the sort order.\n"
2659-
"Alternatively, keylist argument accepts a list on which sort order is based.\n"
2660+
"Alternative to key function is supplying a list to keylist argument,\n"
2661+
"which will determine sort order and will be modified in place.\n"
26602662
"The reverse flag can be set to request the result in descending order.\n"
26612663
"Both key and keylist can not be used at the same time.");
26622664

0 commit comments

Comments
 (0)