我有一个要排序的对象列表。每个对象都有一个ID,它是一个字符串列表。所以我定义了:class MyObject(object): ... def __cmp__(self, other): return self.id.__cmp__(other.id)对python(2.7)说的object 'list' has no attribute '__cmp__'因此,我定义了六个“丰富的比较” ...但是还有更好的方法吗?
添加回答
举报
0/150
提交
取消