Skip to content

Commit 5341e3a

Browse files
committed
builtins docs
1 parent 7d19a8a commit 5341e3a

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

Doc/library/functions.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1840,7 +1840,7 @@ are always available. They are listed here in alphabetical order.
18401840
Slice objects are now :term:`hashable` (provided :attr:`~slice.start`,
18411841
:attr:`~slice.stop`, and :attr:`~slice.step` are hashable).
18421842

1843-
.. function:: sorted(iterable, /, *, key=None, reverse=False)
1843+
.. function:: sorted(iterable, /, *, key=None, keylist=None, reverse=False)
18441844

18451845
Return a new sorted list from the items in *iterable*.
18461846

@@ -1850,6 +1850,10 @@ are always available. They are listed here in alphabetical order.
18501850
key from each element in *iterable* (for example, ``key=str.lower``). The
18511851
default value is ``None`` (compare the elements directly).
18521852

1853+
Alternative to key function is supplying a :class:`list` object
1854+
to *keylist* argument, which will determine the sort order.
1855+
Provided :class:`list` object will be modified in place.
1856+
18531857
*reverse* is a boolean value. If set to ``True``, then the list elements are
18541858
sorted as if each comparison were reversed.
18551859

@@ -1872,6 +1876,11 @@ are always available. They are listed here in alphabetical order.
18721876

18731877
For sorting examples and a brief sorting tutorial, see :ref:`sortinghowto`.
18741878

1879+
.. versionchanged:: 3.15
1880+
1881+
Added *keylist* argument.
1882+
1883+
18751884
.. decorator:: staticmethod
18761885

18771886
Transform a method into a static method.

Doc/library/stdtypes.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,8 +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.
1417+
Alternative to key function is supplying a :class:`list` object
1418+
to *keylist* argument, which will determine the sort order.
1419+
Provided :class:`list` object will be modified in place.
14191420

14201421
*reverse* is a boolean value. If set to ``True``, then the list elements
14211422
are sorted as if each comparison were reversed.

0 commit comments

Comments
 (0)