Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python sort by value first then key lexicography

>>> d = {'T': 1500, 'L': 1000, 'P': 1500, 'G': 6500, 'B': 7000}
>>> sorted(sorted(d), key=d.get, reverse=True)
['B', 'G', 'P', 'T', 'L']
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #sort #key #lexicography
ADD COMMENT
Topic
Name
1+2 =