Question

PYTHON NEED HELP QUICKLY SORTING DICTIONARY Here is my dictionary = {'action': [[('action', 1981, 2060000.0, 120000.0,...

PYTHON NEED HELP QUICKLY SORTING DICTIONARY

Here is my dictionary = {'action': [[('action', 1981, 2060000.0, 120000.0, 0.0, 20000.0, 2200000.0)], [('action', 1981, 1840000.0, 110000.0, 0.0, 20000.0, 1970000.0)], [('action', 1989, 450000.0, 20000.0, 0.0, 10000.0, 480000.0)], [('action', 1987, 440000.0, 20000.0, 0.0, 0.0, 460000.0)], [('action', 1983, 430000.0, 30000.0, 0.0, 0.0, 460000.0)], [('action', 2013, 1400000.0, 1010000.0, 460000.0, 230000.0, 3100000.0)], [('action', 2015, 1150000.0, 550000.0, 470000.0, 170000.0, 2340000.0)], [('action', 1992, 2210000.0, 960000.0, 540000.0, 130000.0, 3840000.0)], [('action', 2002, 2600000.0, 990000.0, 890000.0, 130000.0, 4610000.0)], [('action', 2001, 2380000.0, 670000.0, 460000.0, 100000.0, 3610000.0)], [('action', 1998, 4099999.9999999995, 1890000.0, 1450000.0, 160000.0, 7600000.0)], [('action', 2000, 1900000.0, 670000.0, 730000.0, 60000.0, 3360000.0)], [('action', 1986, 3740000.0, 930000.0, 1690000.0, 140000.0, 6500000.0)], [('action', 1986, 1330000.0, 310000.0, 1040000.0, 50000.0, 2730000.0)]]

It needs to look like : {'action': [('action', 1998, 4099999.9999999995, 1890000.0, 1450000.0, 160000.0, 7600000.0), ('action', 1986, 3740000.0, 930000.0, 1690000.0, 140000.0, 6500000.0), ('action', 2002, 2600000.0, 990000.0, 890000.0, 130000.0, 4610000.0), ('action', 1992, 2210000.0, 960000.0, 540000.0, 130000.0, 3840000.0), ('action', 2001, 2380000.0, 670000.0, 460000.0, 100000.0, 3610000.0), ('action', 2000, 1900000.0, 670000.0, 730000.0, 60000.0, 3360000.0), ('action', 2013, 1400000.0, 1010000.0, 460000.0, 230000.0, 3100000.0), ('action', 1986, 1330000.0, 310000.0, 1040000.0, 50000.0, 2730000.0), ('action', 2015, 1150000.0, 550000.0, 470000.0, 170000.0, 2340000.0), ('action', 1981, 2060000.0, 120000.0, 0.0, 20000.0, 2200000.0), ('action', 1981, 1840000.0, 110000.0, 0.0, 20000.0, 1970000.0), ('action', 1989, 450000.0, 20000.0, 0.0, 10000.0, 480000.0), ('action', 1987, 440000.0, 20000.0, 0.0, 0.0, 460000.0), ('action', 1983, 430000.0, 30000.0, 0.0, 0.0, 460000.0)]

by sorting from the 7th value

Any help??

0 0
Add a comment Improve this question Transcribed image text
Answer #1

sortedList = sorted(f['action'],key = lambda x:-1*x[0][6])#sort by the 7th element of the first element
#(first element is the tuple)
f['action']=sortedList

Add a comment
Know the answer?
Add Answer to:
PYTHON NEED HELP QUICKLY SORTING DICTIONARY Here is my dictionary = {'action': [[('action', 1981, 2060000.0, 120000.0,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT