ネストされた辞書の内部値に基づいて Python 辞書をどのようにソートしますか?
たとえばmydict
、 の値に基づいて以下を並べ替えcontext
ます。
mydict = {
'age': {'context': 2},
'address': {'context': 4},
'name': {'context': 1}
}
結果は次のようになります。
{
'name': {'context': 1},
'age': {'context': 2},
'address': {'context': 4}
}