mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Add list.sorted() classmethod.
This commit is contained in:
parent
c43a7e7c37
commit
0a9b9da0c3
5 changed files with 113 additions and 6 deletions
|
@ -78,6 +78,11 @@ class UserList:
|
|||
def index(self, item, *args): return self.data.index(item, *args)
|
||||
def reverse(self): self.data.reverse()
|
||||
def sort(self, *args, **kwds): self.data.sort(*args, **kwds)
|
||||
def sorted(cls, iterable, *args, **kwds):
|
||||
s = cls(iterable)
|
||||
s.sort(*args, **kwds)
|
||||
return s
|
||||
sorted = classmethod(sorted)
|
||||
def extend(self, other):
|
||||
if isinstance(other, UserList):
|
||||
self.data.extend(other.data)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue