我需要对我的 django 查询集结果进行排序(前五个大值)
我按选择排序排序
def sortTopFive(allPois): # selection sort
res=[]
for i in range(0,4):
large =allPois[i]
for ele in range(i, len(allPois)):
if allPois[ele]['count']>=large['count']:
ele, large = large , ele
else :
continue
res[i]=large
return res
all[i]['count'] 是一个整数
我得到的错误是
'int' object is unsubscriptable
这个问题可能太愚蠢了,我是 python 新手