[Tutor] Grouping based on attributes of elements in a List

Sander Sweers sander.sweers at gmail.com
Wed Mar 30 00:52:54 CEST 2011

On 30 March 2011 00:30, Alan Gauld <alan.gauld at btinternet.com> wrote:
> Wouldn't you just return a tuple of the two elements?
> Or am I missing something having jumped into the middle of the thread...

Ah yes, you are correct. But imo reading "key=lambda l: (l[1], l[0],
l[2])" (which would be needed to sort how the OP wanted) hurts my eyes
;-). Anyway, both options will work fine for the OP.


More information about the Tutor mailing list