Sorting out sort (Re: Python vs. Ruby)

John Roth johnroth at ameritech.net
Fri Jan 3 09:29:54 EST 2003


"Anders J. Munch" <andersjm at dancontrol.dk> wrote in message
news:3e144c3a$0$71645$edfadb0f at dread11.news.tele.dk...
> "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?

Something that chains properly.

John Roth

>
> - Anders
>
>






More information about the Python-list mailing list