I have a dictionary that looks like:
myDict = { "age":value1,"size":value2,'weigth':value3 ... }
And I simply want to get a list of values from this dictionary BUT in some order defined by a list:
order_list = ["age","weigth","size", ... ]
So the result will be:
result_list = [value1,value3,value2, ... ]
The simplest way is to iterate through the order_list
this way:
for key in order_list:
result_list.append(myDict[key])
But I beleive that there is a more efficient and clean way to do what I am trying to do as this method is expensive for two reasons:
- The column list is very long
- I need to do this 1000 time / second