[Python-Dev] Re: lists v. tuples

Michael Hudson mwh@python.net
Mon, 17 Mar 2003 11:33:30 +0000


Christian Tismer <tismer@tismer.com> writes:

>  >>> a=[1, 2, 2+2j, 3+1j, 1+3j, 3-3j, 3+1j, 1+3j]
>  >>> a.sort(lambda x, y:cmp(abs(x), abs(y)))
>  >>> a
> [1, 2, (2+2j), (3+1j), (1+3j), (3+1j), (1+3j), (3-3j)]
>  >>>

Ooh, now I get to mention the list.sort feature request I came up with
this weekend <wink>:

I'd like to be able to write the above call as:

>>> a.sort(key=abs)

Cheers,
M.

-- 
112. Computer Science is embarrassed by the computer.
  -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html