This is a bit more complicated than you need. This will work:
def sort_by_attr_inplace(seq, attr):
import operator
seq.sort(key=operator.attrgetter(attr))
--Ned.
http://nedbatchelder.com
joshuajonah wrote:
> Resolved.
>
> Answer for those interested:
>
> def sort_by_
Resolved.
Answer for those interested:
def sort_by_attr(seq, attr):
import operator
intermed = map(None, map(getattr, seq, (attr,)*len(seq)),
xrange(len(seq)), seq)
intermed.sort()
return map(operator.getitem, intermed, (-1,) *
len(intermed
Ok i have a list of form fields, i want to sort the list by the
".label" of the fields.
I have tried a many different ways but i cant seem to make this work.
I know this is more of a python question but this is the best resource
I've found for these questions.
Can anybody throw an example up for
3 matches
Mail list logo