[Tutor] sorting objects on two attributes

Eric Abrahamsen eric at abrahamsen.com
Tue Mar 4 04:44:32 CET 2008


On Mar 4, 2008, at 11:04 AM, Kent Johnson wrote:

> Eric Abrahamsen wrote:
>> Itertools.groupby is totally impenetrable to me
>
> Maybe this will help:
> http://personalpages.tds.net/~kent37/blog/arch_m1_2005_12.html#e69
>
> Kent
>

It did! Thanks very much. I think I understand now what's going on in  
the groupby line. And then this line:

t.append((sorted_part[-1].submit_date, key, sorted_part))

is basically a Decorate-Sort-Undecorate operation, sorting on  
sorted_part[-1].submit_date because that's guaranteed to be the latest  
date in each group?

It's starting to come clear...


More information about the Tutor mailing list