Created
September 17, 2017 22:35
-
-
Save jtara1/574e87ffa1b49ac09a892aad1620f2f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from heapq import * | |
class A: | |
def __init__(self, val): | |
self.val = val | |
def __lt__(self, cmp): | |
"""Overwrite this to do the opposite of what's | |
expected""" | |
return self.val >= cmp.val | |
h = [] | |
heappush(h, A(1)) | |
heappush(h, A(2)) | |
heappush(h, A(0)) | |
print(heappop(h).val) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment