I want to print a sorted dictionary, which contains a lot of key value pairs (~2000). Each pair consists of a number as the key and a string as the value. It is just about printing, i don't want to sort the dictionary actually.
If i use the sorted()
method, python sorts my dictionary, but in an awkward way:
{'0':'foo', '1':'bar', '10': 'foofoo', '100': 'foobar', '1000': 'barbar',
'1001': 'barfoo', '1002': 'raboof', ...}
But I want to sort it the 'conventional' way like this:
{'0':'foo', '1':'bar', '2': 'foofoo', '3': 'foobar', '4': 'barbar',
'5': 'barfoo', ... , '1001': 'raboof'}
Can I force the method to behave how I want to, or is there another better solution?