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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4