I have a dictionary of 200,000 items (the keys are strings and the values are integers).
What is the best/most pythonic way to print the items sorted by descending v
>>> keys = sorted(a, key=lambda k: (-a[k], k))
or
>>> keys = sorted(a) >>> keys.sort(key=a.get, reverse=True)
then
print [(key, a[key]) for key in keys] [('keyB', 2), ('keyA', 1), ('keyC', 1)]