class C:
def __init__(self,n,x):
self.n = n
self.x = x
a = C('a',1)
b = C('b',2)
c = C('c',3)
classList = [b,a,c]
for q in classList: print q.n,
classList.sort(lambda a,b: long(a.x - b.x))
for q in classList: print q.n,
运行上面的代码会出现错误
TypeError: comparison function must return int, not long
。有没有另一种干净的方法可以按照某些类变量对类对象进行排序?