ok, so how do I return a sorted list without doing it in place

Aahz Maruch aahz at panix.com
Fri Feb 16 21:48:52 EST 2001


In article <mailman.982369099.4358.python-list at python.org>,
Timothy Grant  <tjg at exceptionalminds.com> wrote:
>On Fri, Feb 16, 2001 at 04:04:10PM -0800, Sean 'Shaleh' Perry wrote:
>> I know I can do:
>> 
>> list = dict.keys()
>> list.sort()
>> .....
>> 
>> but it is just plain annoying.
>
>I agree. This has bitten me on the butt more than once. It also seems
>somewhat unPythonic. Usually I expect what happens in Python, but that 
>sort process always strikes me as unexpected.

It's unexpected in some respects, but doing it this way causes the
fewest surprises overall.  At least you rarely get a downstream bug
this way.
-- 
                      --- Aahz (Copyright 2001 by aahz at pobox.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

Why doesn't "Just Say NO" include caffeine, nicotine, alcohol, Prozac,
and Ritalin?  --Aahz



More information about the Python-list mailing list