summaryrefslogtreecommitdiff
path: root/Lib/UserList.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2003-10-29 06:54:43 +0000
committerRaymond Hettinger <python@rcn.com>2003-10-29 06:54:43 +0000
commit4d86678a0547513d9b4ffb94d86ef013fda1ff9a (patch)
treefe28ad4ba3bb4d4c7fc0a129d36c1735fbfd8214 /Lib/UserList.py
parentcf2eac714b2746b5bd96f8e65220ba008a4bb50f (diff)
downloadcpython-4d86678a0547513d9b4ffb94d86ef013fda1ff9a.tar.gz
Add list.sorted() classmethod.
Diffstat (limited to 'Lib/UserList.py')
-rw-r--r--Lib/UserList.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/UserList.py b/Lib/UserList.py
index 072f6a7327..e8fd356adb 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)