Sorting out sort (Re: Python vs. Ruby)

Anders J. Munch andersjm at dancontrol.dk
Thu Jan 2 09:27:05 EST 2003


"John Roth" <johnroth at ameritech.net> wrote:
> > How about adding this to the library somewhere?
> 
> This version unfortunately doesn't allow chained application. - it's purely
> a functional version. 

It was intended to be a purely functional version.  It doesn't chain,
but then it doesn't need to.  Say we add a functional reverse also:
 
def reverse(sequence):
    """reverse a sequence, returning a new list"""
    reversed = list(sequence)
    reversed.reverse()
    return reversed

print reverse(sort([1,4,2,3]))

What more do you need?

- Anders






More information about the Python-list mailing list