17 Mar
2003
17 Mar
'03
6:33 a.m.
Christian Tismer
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