From b4e1b92aabcd302ac54fa58cd4fee8a138dbb5aa Mon Sep 17 00:00:00 2001 From: Adam Niederer Date: Sun, 5 Mar 2017 11:56:05 -0500 Subject: [PATCH] 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. --- Doc/library/heapq.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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. -- 2.40.0