From a2779a0bdea5d94df7998ac58b70e2425bf852b3 Mon Sep 17 00:00:00 2001 From: Adam Niederer Date: Sat, 25 Feb 2017 16:50:57 -0500 Subject: [PATCH] Docs: Add note regarding "reversed" flag in heapq.merge 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 7e33e7481467fa..e36ca8d7b34b13 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.