python sort by value first then key lexicography

Solutions on MaxInterview for python sort by value first then key lexicography by the best coders in the world

showing results for - "python sort by value first then key lexicography"
Bobbie
03 Oct 2018
1>>> d = {'T': 1500, 'L': 1000, 'P': 1500, 'G': 6500, 'B': 7000}
2>>> sorted(sorted(d), key=d.get, reverse=True)
3['B', 'G', 'P', 'T', 'L']
4
similar questions