users = [ {"name" : "dewei"}, {"name" : "xiaomu"}, {"name" : "asan"} ] users.sort(key=lambda x : x['name']) print(users) # [{'name': 'asan'}, {'name': 'dewei'}, {'name': 'xiaomu'}] values 按照从小到大排序
python 字典
最新推荐文章于 2024-08-30 10:02:47 发布
users = [ {"name" : "dewei"}, {"name" : "xiaomu"}, {"name" : "asan"} ] users.sort(key=lambda x : x['name']) print(users) # [{'name': 'asan'}, {'name': 'dewei'}, {'name': 'xiaomu'}] values 按照从小到大排序