Sorting a list of classes
nospam at nowhere.net
Wed Apr 26 00:56:36 EDT 2000
No, you can sort classes, too. It is very useful if you want to sort a list
of plug-ins in a pull-down menu.
className = "A"
className = "B"
className = "C"
classList = [B, C, A]
print "before sorting:", classList
classList.sort(lambda a, b: cmp(a.className, b.className))
print "after sorting:", classList
NOSPAMjchen at NOSPAMquark.com
"Michael Hudson" <mwh21 at cam.ac.uk> wrote in message
news:m3snwafxek.fsf at atrus.jesus.cam.ac.uk...
> "lexberezhny" <lexberezhny at email.msn.com> writes:
> > If i have a python list of classes, can i do something like
> > classList.sort() and how can i control this behavior within the
> > classes.
> Do you mean "class"? In which case, no. If you mean "instance", then
> see the other replies...
> 41. Some programming languages manage to absorb change, but
> withstand progress.
> -- Alan Perlis, http://www.cs.yale.edu/~perlis-alan/quotes.html
More information about the Python-list