Docs: Add note regarding "reversed" flag in heapq.merge (#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.
This commit is contained in:
Adam Niederer 2017-03-05 11:56:05 -05:00 committed by Raymond Hettinger
parent 2a7bddaab7
commit b4e1b92aab
1 changed files with 3 additions and 1 deletions

View File

@ -100,7 +100,9 @@ The module also offers three general purpose functions based on heaps.
``None`` (compare the elements directly).
*reverse* is a boolean value. If set to ``True``, then the input elements
are merged as if each comparison were reversed.
are merged as if each comparison were reversed. To achieve behavior similar
to ``sorted(itertools.chain(*iterables), reverse=True)``, all iterables must
be sorted from largest to smallest.
.. versionchanged:: 3.5
Added the optional *key* and *reverse* parameters.