Created
February 12, 2019 15:26
-
-
Save mdellavo/b57ea78ab42636cae43ea6a3b4d40d91 to your computer and use it in GitHub Desktop.
This file contains 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 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