Skip to content

Commit 69cb6ea

Browse files
committed
#22237: merge with 3.4.
2 parents 0f1c7c7 + 3916241 commit 69cb6ea

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Doc/library/functions.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,11 @@ are always available. They are listed here in alphabetical order.
12861286
Use :func:`functools.cmp_to_key` to convert an old-style *cmp* function to a
12871287
*key* function.
12881288

1289+
The built-in :func:`sorted` function is guaranteed to be stable. A sort is
1290+
stable if it guarantees not to change the relative order of elements that
1291+
compare equal --- this is helpful for sorting in multiple passes (for
1292+
example, sort by department, then by salary grade).
1293+
12891294
For sorting examples and a brief sorting tutorial, see `Sorting HowTo
12901295
<http://wiki.python.org/moin/HowTo/Sorting/>`_\.
12911296

Doc/library/heapq.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ pushing all values onto a heap and then popping off the smallest values one at a
135135
time::
136136

137137
>>> def heapsort(iterable):
138-
... 'Equivalent to sorted(iterable)'
139138
... h = []
140139
... for value in iterable:
141140
... heappush(h, value)
@@ -144,6 +143,9 @@ time::
144143
>>> heapsort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])
145144
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
146145

146+
This is similar to ``sorted(iterable)``, but unlike :func:`sorted`, this
147+
implementation is not stable.
148+
147149
Heap elements can be tuples. This is useful for assigning comparison values
148150
(such as task priorities) alongside the main record being tracked::
149151

0 commit comments

Comments
 (0)