This might help you.

http://blog.modp.com/2008/09/sorting-python-dictionary-by-value-take.html


Robert

Joe Python wrote:
Hi Pythonistas,

I have a large dictionary of dictionary (50,000+ keys) which has a structure as follows:
DoD = {
        'flintstones' : {
        'husband'   : "fred",
        'pal'       : "barney",
        'income'    :  500,
    },
    'jetsons' : {
        'husband'   : "george",
        'wife'      : "jane",
        'his boy' : "elroy",
        'income'    :  700,
    },
    'simpsons' : {
        'husband'   : "homer",
        'wife'      : "marge",
        'kid'       : "bart",
        'income'    :  600,
    },
};

I want to sort the dictionary by 'income'
Is there an efficient way to do the same.
Thanks in advance.

- Jo

_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to