python dic sort code example
Example 1: sort a dictionary
from operator import itemgetter
new_dict = sorted(data.items(), key=itemgetter(1))
Example 2: dict sort
[(k,di[k]) for k in sorted(di.keys())]
from operator import itemgetter
new_dict = sorted(data.items(), key=itemgetter(1))
[(k,di[k]) for k in sorted(di.keys())]