Sorting list of objects on arbitrary attribute

Emile van Sebille emile at fenx.com
Thu Jul 18 09:23:16 EDT 2002


Max M
> But usually when I think up something clever it is allready included
in
> the standard library, or somebody has a 2 liner which does the same
thing.

aList.sort(lambda x,y: cmp( (x.name, x.age, x.rand) , (y.name, y.age,
y.rand) ) )

--

Emile van Sebille
emile at fenx.com

---------




More information about the Python-list mailing list