Simplified ListMixin.sort().
This commit is contained in:
parent
583b9fc410
commit
4441778c26
|
@ -210,19 +210,9 @@ class ListMixin:
|
|||
"Standard list reverse method"
|
||||
self[:] = self[-1::-1]
|
||||
|
||||
def sort(self, cmp=None, key=None, reverse=False):
|
||||
def sort(self, key=None, reverse=False):
|
||||
"Standard list sort method"
|
||||
if key:
|
||||
temp = [(key(v), v) for v in self]
|
||||
temp.sort(key=lambda x: x[0], reverse=reverse)
|
||||
self[:] = [v[1] for v in temp]
|
||||
else:
|
||||
temp = list(self)
|
||||
if cmp is not None:
|
||||
temp.sort(cmp=cmp, reverse=reverse)
|
||||
else:
|
||||
temp.sort(reverse=reverse)
|
||||
self[:] = temp
|
||||
self[:] = sorted(self, key=key, reverse=reverse)
|
||||
|
||||
# ### Private routines ###
|
||||
def _rebuild(self, newLen, newItems):
|
||||
|
|
Loading…
Reference in New Issue