在python中对列表列表进行排序时输出错误

在python中对列表列表进行排序时输出错误,python,list,sorting,Python,List,Sorting,我有以下列表示例: [[0.7578684, 'Yes, import function which lets you load items'],[1.7032554, 'Use the Test tools to edit'], [0.58279467, 'Yes, use the Designer UI Import feature to restore content from the JSON file.']] 我想根据每个列表中的整数值,按降序对该列表进行排序。我写了这些行,但输出错

我有以下列表示例:

[[0.7578684, 'Yes, import function which lets you load items'],[1.7032554, 'Use the Test tools to edit'], [0.58279467, 'Yes, use the Designer UI Import feature to restore content from the JSON file.']]
我想根据每个
列表
中的
整数
值,按
降序对该
列表
进行排序。我写了这些行,但输出错误:

sorted_answer = answer.sort(key=lambda x: float(x[0]),reverse = True)
print(sorted_answer)

执行此操作时,我得到
None
作为
sorted\u应答的输出。我犯了什么错误?

您可以在适当的位置对列表进行排序,排序后返回无。如果需要排序返回函数,请使用排序返回函数

answer.sort(key=lambda x: float(x[0]),reverse = True)
print(answer)
---更新---
我不知道。为什么人们反对投票。
answer.sort(key=lambda x:float(x[0]),reverse=True)
返回
None
并且po assign返回到answer,因此答案是
None
。排序功能已就位,无需重新分配

sorted(answer, reverse=True)
给予


排序正在应用于回答,请尝试打印answer@depperm否,response.sort()返回值为None,不需要赋值back@depperm回答。排序()已就位@我同意。真的
[[1.7032554, 'Use the Test tools to edit'], 
[0.7578684, 'Yes, import function which lets you load items'], 
[0.58279467, 'Yes, use the Designer UI Import feature to restore content from the JSON file.']]