sorting nested dictionary
dsavitsk
dsavitsk at e-coli.net
Tue Mar 12 16:13:45 EST 2002
i have a dictionary that looks something like the following:
{'ids': {'2778xxxxx': {'weighted': 4.6, 'raw': 5.0},
'3059xxxxx': {'weighted': 6.1, 'raw': 6.0},
'3188xxxxx': {'weighted': 3.2, 'raw': 4.0},
'3216xxxxx': {'weighted': 10.1, 'raw': 7.0},
'3257xxxxx': {'weighted': 9.7, 'raw': 9.0},
'3266xxxxx': {'weighted': 4.8, 'raw': 3.0},}}
i would like to sort this portion by 'weighted'. is there a quick (as in
programming time, not sorting time) better way to do this other than dumping
the values to a list, sorting, and realigning the data? that seems so
unpythonic to me somehow.
thanks,
doug
More information about the Python-list
mailing list