<div dir="ltr"><div style="font-family: arial, sans-serif; font-size: 12.8px;">Or if we are willing to make bigger changes to the module, there should be a sort of class that can remember if it is supposed to represent a min-heap or a max-heap. This has been discussed several times:</div><div style="font-family: arial, sans-serif; font-size: 12.8px;"><ul><li style="margin-left: 15px;"><a href="https://groups.google.com/d/topic/python-ideas/h3WLmpBG4ug/discussion" target="_blank" data-saferedirecturl="https://www.google.com/url?hl=en&q=https://groups.google.com/d/topic/python-ideas/h3WLmpBG4ug/discussion&source=gmail&ust=1520580449909000&usg=AFQjCNGTzTTxmL0crsgzl1kQ4DZoQxbCSQ" style="color: rgb(17, 85, 204);">https://groups.google.com/d/<wbr>topic/python-ideas/<wbr>h3WLmpBG4ug/discussion</a><br></li><li style="margin-left: 15px;"><a href="https://groups.google.com/d/topic/python-ideas/WQMhF79oCzw/discussion" target="_blank" data-saferedirecturl="https://www.google.com/url?hl=en&q=https://groups.google.com/d/topic/python-ideas/WQMhF79oCzw/discussion&source=gmail&ust=1520580449909000&usg=AFQjCNGB2HCD58PqwBp0AS2aXhrvCqWZpQ" style="color: rgb(17, 85, 204);">https://groups.google.com/d/<wbr>topic/python-ideas/<wbr>WQMhF79oCzw/discussion</a><br></li><li style="margin-left: 15px;"><a href="https://groups.google.com/d/topic/python-ideas/NmL53DLTqpo/discussion" target="_blank" data-saferedirecturl="https://www.google.com/url?hl=en&q=https://groups.google.com/d/topic/python-ideas/NmL53DLTqpo/discussion&source=gmail&ust=1520580449909000&usg=AFQjCNHY_CjZs8g-ur19_isskHFWs3rhDA" style="color: rgb(17, 85, 204);">https://groups.google.com/d/<wbr>topic/python-ideas/<wbr>NmL53DLTqpo/discussion</a><br></li><li style="margin-left: 15px;"><a href="https://groups.google.com/d/topic/python-ideas/cLIAhBbQ8xA/discussion" target="_blank" data-saferedirecturl="https://www.google.com/url?hl=en&q=https://groups.google.com/d/topic/python-ideas/cLIAhBbQ8xA/discussion&source=gmail&ust=1520580449909000&usg=AFQjCNHepvYb7F4d7m6A7rJWyykklhJs0g" style="color: rgb(17, 85, 204);">https://groups.google.com/d/<wbr>topic/python-ideas/<wbr>cLIAhBbQ8xA/discussion</a><br></li></ul><div>But nothing definite has come out of those discussions, as far as I can tell.</div></div><br>On Tuesday, March 6, 2018 at 9:59:00 AM UTC-8, Neil Girdhar wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir="ltr">heapq creates and works with min-heaps.  Currently, the only way to do this is to use _heapify_max instead of heapify, heapq._heappop_max instead of heapq.heappop, etc.<br><div><br></div><div>These methods should be exposed using a reverse keyword argument rather than as private methods just like sort.</div><div><br></div><div>Best,</div><div><br></div><div>Neil</div></div></blockquote></div>