I have a dictionary like this:
A = {\'a\':10, \'b\':843, \'c\': 39,.....}
I want to get the 5 maximum values of this dict and store a new d
For Python 3
import operator dict(sorted(A.items(), key=operator.itemgetter(1), reverse=True)[:5])