summaryrefslogtreecommitdiffstats
path: root/Doc/library/heapq.rst
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2014-10-28 11:57:11 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2014-10-28 11:57:11 (GMT)
commit9b1e92f5a199acf20041372950b96e5896e1b634 (patch)
tree629a2e1d55b45f316cd54826656a4d2d2dfd2fd5 /Doc/library/heapq.rst
parent16e7f97bcbcd14d3ef0ceb0947714e382dafe1e6 (diff)
downloadcpython-9b1e92f5a199acf20041372950b96e5896e1b634.zip
cpython-9b1e92f5a199acf20041372950b96e5896e1b634.tar.gz
cpython-9b1e92f5a199acf20041372950b96e5896e1b634.tar.bz2
#22237: document that sorted() is guaranteed to be stable. Initial patch by Martin Panter.
Diffstat (limited to 'Doc/library/heapq.rst')
-rw-r--r--Doc/library/heapq.rst4
1 files changed, 3 insertions, 1 deletions
diff --git a/Doc/library/heapq.rst b/Doc/library/heapq.rst
index 4f1a682..6a61480 100644
--- a/Doc/library/heapq.rst
+++ b/Doc/library/heapq.rst
@@ -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::