<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Keeping Dictionaries in Order
Problem
You want to create a dictionary, and you also want to control the order of items when iterating or serializing.
Solution
To control the order of items in a dictionary, you can use an OrderedDict from the collections module.
Step1:  An OrderedDict can be particularly useful when you want to build a mapping that you may want to later serialize or encode into a different format. For example, if you want to precisely control the order of fields appearing in a JSON encoding, first building the data in an OrderedDict will do the trick
<ASSISTANT_TASK:>
Python Code:
from collections import OrderedDict
d = OrderedDict()
d['foo'] = 1
d['bar'] = 2
d['spam'] = 3
d['grok'] = 4
# Outputs "foo 1", "bar 2", "spam 3", "grok 4"
for key in d: 
    print(key, d[key])
Explanation: Keeping Dictionaries in Order
Problem
You want to create a dictionary, and you also want to control the order of items when iterating or serializing.
Solution
To control the order of items in a dictionary, you can use an OrderedDict from the collections module.
End of explanation
import json
json.dumps(d)
Explanation: An OrderedDict can be particularly useful when you want to build a mapping that you may want to later serialize or encode into a different format. For example, if you want to precisely control the order of fields appearing in a JSON encoding, first building the data in an OrderedDict will do the trick:
End of explanation
<END_TASK>