[Tutor] Sorting a list of objects on different fields

Terry Carroll carroll at tjc.com
Thu Mar 2 22:45:25 CET 2006

On Thu, 2 Mar 2006, Kent Johnson wrote:

> In [9]: lst.sort(key=attrgetter('b')); print lst

Thanks, Kent!  I didn't know about "key=".  I see it's new in 2.4.

I was thinking I'd have to put in a method for each potentially sortable 

More information about the Tutor mailing list