mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
#22237: document that sorted() is guaranteed to be stable. Initial patch by Martin Panter.
This commit is contained in:
parent
16e7f97bcb
commit
9b1e92f5a1
2 changed files with 8 additions and 1 deletions
|
@ -123,7 +123,6 @@ pushing all values onto a heap and then popping off the smallest values one at a
|
|||
time::
|
||||
|
||||
>>> def heapsort(iterable):
|
||||
... 'Equivalent to sorted(iterable)'
|
||||
... h = []
|
||||
... for value in iterable:
|
||||
... heappush(h, value)
|
||||
|
@ -132,6 +131,9 @@ time::
|
|||
>>> heapsort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])
|
||||
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||
|
||||
This is similar to ``sorted(iterable)``, but unlike :func:`sorted`, this
|
||||
implementation is not stable.
|
||||
|
||||
Heap elements can be tuples. This is useful for assigning comparison values
|
||||
(such as task priorities) alongside the main record being tracked::
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue