13 Jan
2004
13 Jan
'04
5:17 p.m.
On Tue, Jan 13, 2004 at 12:47:37AM -0800, Alec Mitchell wrote:
in this case it would be:
def sort_by_field(list, f): decorated = [(getattr(obj, f), obj) for obj in list] decorated.sort() return [a[1] for a in decorated]
That's fine, but dont't get in the habit of using "list" as a variable name. There is a python built-in with the same name! Hiding builtins is likely to be cause bugs sooner or later. -- Paul Winkler http://www.slinkp.com Look! Up in the sky! It's BASTARD-HUGGER! (random hero from isometric.spaceninja.com)