I have a recorder like:
original_dict = {'two':'2','three':'3','one':'1','foo':'squirrel'}
And I wanted the two to be in the following order:
ordered_dict = OrderedDict({'one':'1','two':'2','three':'3','foo':'squirrel'})
but I don't get the same order,
{'one':'1','two':'2','three':'3','foo':'squirrel'}the dict itself creates, so it doesn't work since I sped
I saw in the documentation that a sorted method can be used
OrderedDict(sorted(d.items(), key=lambda t: len(t[0])))
But I donβt know the function to return the order I want I tried
ordered_dict = OrderedDict(sorted(original_dict.items(),['one','two','three','foo']))
But that did not work.
Note that the order I want can be quite arbitrary, for example:
['three','foo','one','two',]