Magnus Lycka wrote: > Actually, I guess it's possible that sorted() is done so > that it works like below, but I don't think pre-sorted() > versions of Python support keyword arguments to list.sort() > anyway... > > def sorted(l, *p, **kw): s=l[:];s.sort(*p, **kw);return s
One part you missed, sorted is actually closer to: def sorted(iterable, cmp=None, key=None, reverse=False): "sorted(iterable, cmp=None, key=None, reverse=False) --> new sorted list" s=list(iterable) s.sort(cmp, key, reverse) return s The point being that while in general only a list will have a sort method, the sorted builtin may be called on any iterable and will return a sorted list. Also note that it only accepts specific named arguments, and has a docstring. -- http://mail.python.org/mailman/listinfo/python-list