我有这段代码,它必须对csv文件中的条目进行排序
with open("file.csv") as file:
reader = csv.reader(file, delimiter=";")
sortedlist = sorted(reader, key=lambda row: row[1], reverse=True)
file.csv
player;money
Jirka;700
Jikra;950
a;1500
Jirka;750
Jirka;700
Jirka;600
Jirka;600
Jirka;1200
Jirka;1000
Jirka;2000
Jirka;4000
Jirka;8000
Jirka;16000
打印变量sortedlist
[['player', 'money'], ['Jikra', '950'], ['Jirka', '8000'], ['Jirka', '750'], ['Jirka', '700'], ['Jirka', '700'], ['Jirka', '600'], ['Jirka', '600'], ['Jirka', '4000'], ['Jirka', '2000'], ['Jirka', '16000'], ['a', '1500'], ['Jirka', '1200'], ['Jirka', '1000']]
如您所见,排序不正确,可能有问题的任何想法吗?