Updated sorted for 2.4 compatibility.

This commit is contained in:
Jeremy Fincher 2004-04-20 10:04:09 +00:00
parent 85807dd077
commit ed8df0a998
2 changed files with 10 additions and 5 deletions

View File

@ -151,7 +151,7 @@ class Topic(callbacks.Privmsg):
except ValueError:
irc.error('The positions must be valid integers.')
return
if utils.sorted(order) != range(num):
if sorted(order) != range(num):
irc.error('Duplicate topic numbers cannot be specified.')
return
try:

View File

@ -394,13 +394,18 @@ def sortBy(f, L, cmp=cmp):
for (i, elt) in enumerate(L):
L[i] = L[i][2]
def sorted(iterable, *args, **kwargs):
"""Returns a sorted list made from iterable. All other args are given to
list.sort unchanged."""
def sorted(iterable, cmp=None, key=None, reversed=False):
L = list(iterable)
L.sort(*args, **kwargs)
if key is not None:
sortBy(key, L, cmp=cmp)
else:
L.sort(cmp)
if reversed:
L.reverse()
return L
__builtins__['sorted'] = sorted
def mktemp(suffix=''):
"""Gives a decent random string, suitable for a filename."""
import sha