Skip to content

Commit

Permalink
corrected refrence to python internal sort method from timsort to pow…
Browse files Browse the repository at this point in the history
…ersort. (#3776)
  • Loading branch information
BethanyG authored Sep 27, 2024
1 parent 6c78db5 commit 2a09812
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
23 changes: 18 additions & 5 deletions concepts/list-methods/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,22 @@ The order of list elements can be reversed _**in place**_ with `<list>.reverse(
[3, 2, 1]
```

List elements can be sorted _**in place**_ using `<list>.sort()`.
Internally, Python uses [`Timsort`][timsort] to arrange the elements.
The default order is _ascending_.
The Python docs have [additional tips and techniques for sorting][sorting how to] `lists` effectively.
A list can be re-ordered _**in place**_ with the help of `<list>.sort()`.
Default sort order is _ascending_ from the left.
The Python docs offer [additional tips and techniques for sorting][sorting how to] lists effectively.


~~~~exercism/note
From 2002 to 2022, Python used an algorithm called [`Timsort`][timsort] internally to arrange lists, but switched to [`Powersort`][powersort] from `Python 3.11` onward.
You can read more details and discussion on the change from the core Python team in the GitHub [issue 78742][78742].
For technical details on the algorithm, see the J. Ian Munro and Sebastian Wild paper [Nearly-Optimal Mergesorts: Fast, Practical Sorting Methods That Optimally Adapt to Existing Runs][nearly-optimal-mergesorts]
[78742]: https://github.com/python/cpython/issues/78742
[nearly-optimal-mergesorts]: https://arxiv.org/abs/1805.04154
[powersort]: https://www.wild-inter.net/publications/munro-wild-2018
[timsort]: https://en.wikipedia.org/wiki/Timsort
~~~~


```python
Expand Down Expand Up @@ -256,5 +268,6 @@ For a detailed explanation of names, values, list, and nested list behavior, tak
[slice notation]: https://docs.python.org/3/reference/expressions.html#slicings
[sorted]: https://docs.python.org/3/library/functions.html#sorted
[sorting how to]: https://docs.python.org/3/howto/sorting.html
[timsort]: https://en.wikipedia.org/wiki/Timsort
[tuple]: https://docs.python.org/3/library/stdtypes.html#tuple


Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,15 @@ The `<list>.reverse()` method will reverse the order of elements **in-place**.


A list can be re-ordered _**in place**_ with the help of `<list>.sort()`.
Internally, Python uses [`Timsort`][timsort] to arrange the list.
Default order is _ascending_ from the left.
The Python docs offer [additional tips and techniques for sorting][sorting how to] lists effectively.
Default sort order is _ascending_ from the left.
The Python docs offer [additional tips and techniques for sorting][sorting how to] lists effectively.

~~~~exercism/note
From 2002 to 2022, Python used an algorithm called [`Timsort`][timsort] internally to arrange lists, but switched to [`Powersort`][powersort] from `Python 3.11` onward.
[powersort]: https://www.wild-inter.net/publications/munro-wild-2018
[timsort]: https://en.wikipedia.org/wiki/Timsort
~~~~


```python
Expand Down Expand Up @@ -244,5 +250,4 @@ ValueError: 10 is not in list
[slice notation]: https://docs.python.org/3/reference/expressions.html#slicings
[sorted]: https://docs.python.org/3/library/functions.html#sorted
[sorting how to]: https://docs.python.org/3/howto/sorting.html
[timsort]: https://en.wikipedia.org/wiki/Timsort
[tuple]: https://docs.python.org/3/library/stdtypes.html#tuple

0 comments on commit 2a09812

Please sign in to comment.