1x = {1: 2, 3: 4, 4: 3, 2: 1, 0: 0}
2{k: v for k, v in sorted(x.items(), key=lambda item: item[1])}
3{0: 0, 2: 1, 1: 2, 4: 3, 3: 4}
1from operator import itemgetter
2new_dict = sorted(data.items(), key=itemgetter(1))
1d = {'apple': 2, 'banana': 3, 'almond':2 , 'beetroot': 3, 'peach': 4}
2[v[0] for v in sorted(d.items(), key=lambda kv: (-kv[1], kv[0]))]