Alan Isaac wrote: > #sort by id and then value > kv_sorted = sorted(kv, key=lambda x: (id(x[0]),x[1])) > #groupby: first element in each group is object and its min value > d =dict( g.next() for k,g in groupby( kv_sorted, key=lambda x: x[0] ) ) > > Yes, that appears to be fastest and is > pretty easy to read.
On average. For the specified problem. ;-) -- http://mail.python.org/mailman/listinfo/python-list