I am trying to sort a dictionary and I have looked at numerous examples but they all show very simple dictionaries. I have looked at orderedDict, itemgetter, lambda etc. but I cannot see how to sort this dictionary either by position, homepoints or awaypoints:
{
u'SwanseaCityFC': {
'position': 12,
'awayPoints': 7,
'homePoints': 8
},
u'TottenhamHotspurFC': {
'position': 6,
'awayPoints': 11,
'homePoints': 9
},
u'StokeCityFC': {
'position': 14,
'awayPoints': 9,
'homePoints': 4
},
u'AstonVillaFC': {
'position': 20,
'awayPoints': 4,
'homePoints': 1
},
u'ManchesterCityFC': {
'position': 1,
'awayPoints': 10,
'homePoints': 12
},
u'AFCBournemouth': {
'position': 17,
'awayPoints': 5,
'homePoints': 5
},
u'CrystalPalaceFC': {
'position': 7,
'awayPoints': 9,
'homePoints': 6
},
u'NewcastleUnitedFC': {
'position': 19,
'awayPoints': 3,
'homePoints': 5
},
u'NorwichCityFC': {
'position': 16,
'awayPoints': 6,
'homePoints': 4
},
u'WatfordFC': {
'position': 13,
'awayPoints': 10,
'homePoints': 5
},
u'ManchesterUnitedFC': {
'position': 4,
'awayPoints': 11,
'homePoints': 11
},
u'LeicesterCityFC': {
'position': 5,
'awayPoints': 10,
'homePoints': 10
},
u'ChelseaFC': {
'position': 15,
'awayPoints': 5,
'homePoints': 7
},
u'WestHamUnitedFC': {
'position': 3,
'awayPoints': 14,
'homePoints': 7
},
u'SunderlandAFC': {
'position': 18,
'awayPoints': 3,
'homePoints': 5
},
u'SouthamptonFC': {
'position': 8,
'awayPoints': 8,
'homePoints': 7
},
u'EvertonFC': {
'position': 11,
'awayPoints': 10,
'homePoints': 5
},
u'LiverpoolFC': {
'position': 9,
'awayPoints': 8,
'homePoints': 8
},
u'ArsenalFC': {
'position': 2,
'awayPoints': 13,
'homePoints': 10
},
u'WestBromwichAlbionFC': {
'position': 10,
'awayPoints': 11,
'homePoints': 4
}
}
Any help appreciated!