A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-March/034105.html below:

[Python-Dev] Re: lists v. tuples

[Python-Dev] Re: lists v. tuplesMichael 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



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