D'oh! That sortlist() function was needlessly clever. This is nicer: >>> def sortlist(L, decorator=None): ... if decorator is None: ... L.sort() ... return ... newL = [(decorator(x), x) for x in L] ... newL.sort() ... L[:] = [y for (x,y) in newL]