Skip to content

Instantly share code, notes, and snippets.

@mdellavo
Created February 12, 2019 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdellavo/b57ea78ab42636cae43ea6a3b4d40d91 to your computer and use it in GitHub Desktop.
Save mdellavo/b57ea78ab42636cae43ea6a3b4d40d91 to your computer and use it in GitHub Desktop.
from functools import total_ordering
@total_ordering
class SortableNone(object):
def __eq__(self, other):
return self is other
def __le__(self, other):
return True
def __bool__(self):
return False
SNone = SortableNone()
print(sorted([4, 15, SNone, 23, SNone, 87, 1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment