On Thu, Feb 11, 2010 at 4:44 AM, Stefan Behnel <stefan...@behnel.de> wrote:

> 2) given that you have lists as items in the 'data' list, it's enough to
> call sort() once, as the comparison of lists is defined as the comparison
> of each item to the corresponding item of the other list. If you want to
> sort based on the second item before the first item, it's best to exchange
> both items before sorting and swap them back afterwards.

No, that is the old decorate-sort-undecorate idiom which has been
replaced by the key= parameter to sort.

data.sort(key=operator.itemgetter(1)) is the best way to sort on the
second item.

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to