2
xxx749 2018-09-13 08:31:29 +08:00 via Android
食谱第一章
|
4
huangmiao233 OP @Sylv 感谢大佬啊。😃
|
6
xpresslink 2018-09-13 11:13:58 +08:00
from operator import attrgetter
class MyObject(object): □□□□def __init__(self, name): self.name = name □□□□def __repr__(self): return self.name list1 = [] for i in range(5): □□□□list1.append(MyObject('object'+str(i))) print(sorted(list1, key=attrgetter('name'), reverse=True)) # [object4, object3, object2, object1, object0] |