diff options
author | Raymond Hettinger <python@rcn.com> | 2003-10-29 06:54:43 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2003-10-29 06:54:43 (GMT) |
commit | 0a9b9da0c39eb74075cc93f7d7bd3b5dbcc25320 (patch) | |
tree | 9f383ec9b1ddc0e5bc09d25cd502aaac2b2432f8 /Lib/UserList.py | |
parent | c43a7e7c370215518ea110f4d98493935bd1c2b8 (diff) | |
download | cpython-0a9b9da0c39eb74075cc93f7d7bd3b5dbcc25320.zip cpython-0a9b9da0c39eb74075cc93f7d7bd3b5dbcc25320.tar.gz cpython-0a9b9da0c39eb74075cc93f7d7bd3b5dbcc25320.tar.bz2 |
Add list.sorted() classmethod.
Diffstat (limited to 'Lib/UserList.py')
-rw-r--r-- | Lib/UserList.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/UserList.py b/Lib/UserList.py index 072f6a7..e8fd356 100644 --- a/Lib/UserList.py +++ b/Lib/UserList.py @@ -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) |