2

I am relatively new to python so I need some help to setup my highest to lowest sorting system for a dictionary. I use:

highestList = sorted(classFile.items(), key=lamda x: x[::-1])

This sorted my dictionary into a tuple but it is the wrong way around. it outputs:

[('Dylan', 4), ('Jimmy', 5), ('Mark', 5), ('Chris', 7)]

Where I would like it to output:

[('Chris', 7), ('Mark', 5), ('Jimmy',5), ('Dylan',4)]
Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Ddude
  • 59
  • 1
  • 2
  • 6
  • Duplicate of [Python list sort in descending order](http://stackoverflow.com/q/4183506) . Voted to reopen by mistake. – Bhargav Rao Dec 06 '15 at 12:17

1 Answers1

1
highestList = sorted(classFile.items(), key=lamda x: x[::-1],reverse=True)

Use reverse=True

Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
vks
  • 67,027
  • 10
  • 91
  • 124