相关疑难解决方法(0)

如何对键进行排序:按列表中的值列出字典?

我有一本字典

mydict = {'name':['peter', 'janice', 'andy'], 'age':[10, 30, 15]}
Run Code Online (Sandbox Code Playgroud)

如何根据key =="name"列表对此词典进行排序?

最终结果应该是:

mydict = {'name':['andy', 'janice', 'peter'], 'age':[15, 30, 10]}
Run Code Online (Sandbox Code Playgroud)

或者字典是这种数据的错误方法?

python sorting dictionary

4
推荐指数
1
解决办法
171
查看次数

标签 统计

dictionary ×1

python ×1

sorting ×1