Created
March 29, 2016 18:04
-
-
Save markddavidoff/a058f4ad57b645f5a47178dc29b1f8c5 to your computer and use it in GitHub Desktop.
SimpleSortedList
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
# idk if this works but it was an idea that popped into my head, saving for later here. | |
class SimpleSortedList(list): | |
def __init__(self, data=None, cmp=None): | |
if data is not None: | |
super(SimpleSortedList, self).__init__(data) | |
else: | |
super(SimpleSortedList, self).__init__() | |
self.cmp = cmp | |
def insert(self, index, p_object): | |
list.insert(self,index,p_object) | |
list.sort(self,self.cmp) | |
def extend(self, iterable): | |
list.extend(self, iterable) | |
list.sort(self,self.cmp) | |
def append(self, p_object): | |
list.append(self, p_object) | |
list.sort(self,self.cmp) | |
def __iadd__(self, other): | |
list.__iadd__(self, other) | |
list.sort(self,self.cmp) | |
def __add__(self, other): | |
list.__iadd__(self, other) | |
list.sort(self,self.cmp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment