[Solved] List to dict: incorrectly sorted result
>>> from collections import OrderedDict >>> sorted_dict = OrderedDict() >>> dct = {1: 2, 3: 4, 4: 3, 2: 1, 0: 0} >>> dct.values().sort() >>> for x in sorted(dct.values(), reverse=True): … keys = [idx for idx in dct if dct[idx]==x] … for key in keys: … sorted_dict[key] = x … >>> >>> sorted_dict OrderedDict([(3, 4), … Read more