From: Adam Niederer Date: Sun, 5 Mar 2017 16:56:05 +0000 (-0500) Subject: Docs: Add note regarding "reversed" flag in heapq.merge (#300) X-Git-Tag: v3.7.0a1~1202 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b4e1b92aabcd302ac54fa58cd4fee8a138dbb5aa;p=python 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. --- diff --git a/Doc/library/heapq.rst b/Doc/library/heapq.rst index 7e33e74814..e36ca8d7b3 100644 --- a/Doc/library/heapq.rst +++ b/Doc/library/heapq.rst @@ -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.