d = {'AAA': 1, 'BBB': 5, 'CCC': 3} for k in sorted(d, key=d.get, reverse=True): print("{} - {}".format(k, d[k]))
Standard input is empty
BBB - 5 CCC - 3 AAA - 1
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!