You could also achieve that using the __cmp__ magic method[1]:
<code>
class a:
def __init__(self, name, number):
self.name = name
self.number = number
def __cmp__(self, other):
return cmp(
self.name,
other.name)
def __repr__(self):
return "a(%s, %s)" % (repr(
self.name), self.number)
b = []
b.append( a('Smith', 1) )
b.append( a('Dave', 456) )
b.append( a('Guran', 9432) )
b.append( a('Asdf', 12) )
b.sort()
print b
# [a('Asdf', 12), a('Dave', 456), a('Guran', 9432), a('Smith', 1)]
</code>
The __cmp__ method does the magic, it's used when you call b.sort().
I added __repr__ just to see legible output...
[1]
http://docs.python.org/ref/customization.html
[]'s
Rodolfo