sort dictionary by specific values

dorje tarap dorjetarap at googlemail.com
Sat Aug 18 14:40:49 EDT 2007


Hi,

I need to perform some horrible functions in python I need to do, using sort
in a similar way that Excel can.

With a dictionary like:
 Code: ( text )

   1. >>> d
   2. {8: (99, 99), 9: [(55, 67), (77, 66), (67, 88)], 4: [(45, 78), (56,
   78), (99, 78)], 5: (67, 77)}


I want to sort the entire dictionary based on the last values in each line.
First for [-1][0] and then[-1][0].

So sorted descending I would like the output to look like:
 Code: ( text )

   1. >>> d
   2. {8: (99, 99), 4: [(45, 78), (56, 78), (99, 78)], 9: [(55, 67), (77,
   66), (67, 88)], 5: (67, 77)}


Many thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070818/1feab1b4/attachment.html>


More information about the Python-list mailing list