Nianbig wrote: > I have a people-list like this: >>>> class a: > ... def __init__(self, name, number): > ... self.name = name > ... self.number = number > ... >>>> b = [] >>>> b.append( a('Smith', 1) ) >>>> b.append( a('Dave', 456) ) >>>> b.append( a('Guran', 9432) ) >>>> b.append( a('Asdf', 12) ) > > How do I sort this on their names e.g. ascending? I have tried > b.sort() and so on in all sorts of ways but I canĀ“t figure this one > out..
this might get you going: def mysortkey(x): return x.name b.sort(key=mysortkey) </F> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---