PyDocs

Nav

Python Runtime Services

list.sort

builtins

method of list
  • list.sort(*, key=None, reverse=False)
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.

The official docs include a CPython implementation detail for this entry.

0 Examples
No examples for builtins/list.sort.
See Also
No see-alsos for builtins/list.sort
0 Notes
No notes for list.sort