A small suggestion for Python

Alex Martelli aleaxit at yahoo.com
Sat Jan 13 18:42:53 EST 2001


"Matt Dunford" <kno at jtan.com> wrote in message
news:G74HuE.AGn.0.sinope at news.jtan.com...
    [snip]
> Although, I wouldn't mind having a builtin method that returns a sorted
> array.  Then we could do something like this:
>
> dict = { 'this' : 1, 'that' : 2 }
> for key in dict.keys().sort():
> print key

And instead we have to do

    for key in return_sorted(dict.keys()):
        print key

Is it that much of a problem...?  return_sorted's pretty trivial too:

def return_sorted(alist):
    alist.sort()
    return alist


Alex






More information about the Python-list mailing list