[Python-Dev] Re: inline sort option

David Eppstein eppstein at ics.uci.edu
Thu Oct 16 14:25:13 EDT 2003


In article <004f01c3940d$ea1c1320$e841fea9 at oemcomputer>,
 "Raymond Hettinger" <python at rcn.com> wrote:

> Are you proposing something like:
> 
>     print mylist.sort(inplace=False)  # prints a new, sorted list while
>                                       # leaving the original list intact

What's wrong with writing your own three-line function

def sort(L):
    copy = list(L)
    copy.sort()
    return copy

then you can do print sort(mylist) etc to your heart's content...

-- 
David Eppstein                      http://www.ics.uci.edu/~eppstein/
Univ. of California, Irvine, School of Information & Computer Science




More information about the Python-Dev mailing list