from collections import OrderedDict
a = {2: {"str1": "str", "str2": "str"}, 1: {"str1": "str", "str2": "str"}, 3: {"str1": "str", "str2": "str"}}
b = OrderedDict(sorted(a.items()))
print(b)
# OrderedDict([(1, {'str1': 'str', 'str2': 'str'}), (2, {'str1': 'str', 'str2': 'str'}), (3, {'str1': 'str', 'str2': 'str'})])