Skip to content

Commit b4e1b92

Browse files
AdamNiedererrhettinger
authored andcommitted
Docs: Add note regarding "reversed" flag in heapq.merge (python#300)
The docs for `heapq.merge` are a little misleading. Iterables passed into heapq.merge with the reversed flag enabled must be sorted from largest to smallest to achieve the desired sorting effect, but the previous paragraph states that they should be sorted from smallest to largest.
1 parent 2a7bdda commit b4e1b92

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Doc/library/heapq.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ The module also offers three general purpose functions based on heaps.
100100
``None`` (compare the elements directly).
101101

102102
*reverse* is a boolean value. If set to ``True``, then the input elements
103-
are merged as if each comparison were reversed.
103+
are merged as if each comparison were reversed. To achieve behavior similar
104+
to ``sorted(itertools.chain(*iterables), reverse=True)``, all iterables must
105+
be sorted from largest to smallest.
104106

105107
.. versionchanged:: 3.5
106108
Added the optional *key* and *reverse* parameters.

0 commit comments

Comments
 (0)