I'm trying to get a list of keys from a dict but I want to preserve the original order of keys in dict.
For example:
import collections
g = {'a' : '1',
'c' : '3',
'd' : '4',
'b' : '2'}
when i run g I get: {'a': '1', 'b': '2', 'c': '3', 'd': '4'}
when i run collections.OrderedDict.fromkeys(g).keys() I get: odict_keys(['b', 'd', 'a', 'c'])
when i run list( collections.OrderedDict.fromkeys(g).keys() ) I get: ['b', 'd', 'a', 'c']
Anybody knows how can I get the initial order, which is: ['a', 'c', 'd', 'b']