[portland] Sorting A List of Tuples
Rich Shepard
rshepard at appl-ecosys.com
Thu Nov 8 18:53:02 CET 2007
On Thu, 8 Nov 2007, jason kirtland wrote:
> The array 'sort' method and the 'sorted' function both take an optional
> 'key' function. The function is applied to each item in the list and the
> result is used for comparison instead of the list value itself.
>
> If you only want to consider the second item in the tuple, the operator
> module's 'itemgetter' is perfect:
Thanks very much, Jason.
Rich
--
Richard B. Shepard, Ph.D. | Integrity Credibility
Applied Ecosystem Services, Inc. | Innovation
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
More information about the Portland
mailing list