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_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))
>
>         def sort_by_attr_inplace(lst, attr):
>             lst[:] = sort_by_attr(lst, attr)
> >
>
>   

-- 
Ned Batchelder, http://nedbatchelder.com


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to