Here is a version based on Andreas' solution using groupby() that avoids 
the decorate-undecorate by using the key= parameter for the second sort:

l.sort(key=lambda x: (x.content_type, x.submit_date))
t = [ list(items) for key, items in itertools.groupby(l, key=lambda x:
(x.content_type)) ]
t.sort(key=lambda x: x[-1].submit_date, x[-1].object_id)

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to