python元组列表排序

list1 = list()
for i in range(5):
        name = input(f'输入水果名字:')
        price = int(input(f'输入水果价格(整数):'))
        list1.append((name,price))
list1.sort(key=lambda x:x[1])
print(list1)

posted @ 2023-12-15 14:20  Danlis  阅读(10)  评论(0编辑  收藏  举报