Skip to content

Instantly share code, notes, and snippets.

@jtara1
Created September 17, 2017 22:35
Show Gist options
  • Save jtara1/574e87ffa1b49ac09a892aad1620f2f7 to your computer and use it in GitHub Desktop.
Save jtara1/574e87ffa1b49ac09a892aad1620f2f7 to your computer and use it in GitHub Desktop.
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