A small suggestion for Python
Matt Dunford
kno at jtan.com
Sun Jan 14 03:34:36 EST 2001
"Alex Martelli" <aleaxit at yahoo.com> writes:
>"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
I have no problem with it. But just to be pendantic, your return_sorted def
doesn't do what I'm trying to get at. I'm thinking more along the lines of
def return_sorted(alist):
import copy
sorted = copy.copy(alist)
sorted.sort()
return sorted
--
More information about the Python-list
mailing list