My apologies if I am using the incorrect terminology, as I’m a bit of a Python n00b when it comes to the proper descriptions for data structures.
I have a data structure that looks like this:
{
u'COU': {'hl': 39, 'hw': 42, 'winPct': Decimal('0.5471698113207547169811320755'), 'al': 36, 'l': 72, 'w': 87, 'aw': 45},
u'MIN': {'hl': 42, 'hw': 39, 'winPct': Decimal('0.3559322033898305084745762712'), 'al': 57, 'l': 114, 'w': 63, 'aw': 24},
u'BOW': {'hl': 36, 'hw': 44, 'winPct': Decimal('0.5432098765432098765432098765'), 'al': 37, 'l': 74, 'w': 88, 'aw': 44}
}
I want to sort this data structure by the value in winPct inside the inner dict and searching online has revealed a dazzling array of advice that makes no sense to this raised-on-PHP developer.
Thanks in advance for your help.
You can’t sort a dictionary, but you could convert the dictionary into a list of tuples with the form
(key, value).To Reverse the sorting as per your comment use: