[Python-Dev] Re: lists v. tuples
Michael Hudson
mwh@python.net
Mon, 17 Mar 2003 11:33:30 +0000
Mon, 17 Mar 2003 11:33:30 +0000
- Previous message: [Python-Dev] Re: lists v. tuples
- Next message: [Python-Dev] Re: lists v. tuples
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] Re: lists v. tuples
- Next message: [Python-Dev] Re: lists v. tuples
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]