### Here is a way we can print dictionaries in order by keys ## Here's a dict to play with >>> dict = {'hi':[1,2,3],'there':[5,4],'bear':[3,3,3]} >>> dict {'there': [5, 4], 'hi': [1, 2, 3], 'bear': [3, 3, 3]} ## There is a list method, sort, that we can use like this: >>> lst = [4,3,5,4] >>> lst.sort() >>> lst [3, 4, 4, 5] >>> help(list.sort) Help on method_descriptor: sort(...) L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*; cmp(x, y) -> -1, 0, 1 >>> lst [3, 4, 4, 5] >>> lst [3, 4, 4, 5] >>> dict {'there': [5, 4], 'hi': [1, 2, 3], 'bear': [3, 3, 3]} >>> dict_keys = dict.keys() >>> dict_keys ['there', 'hi', 'bear'] >>> dict_keys.sort() >>> dict_keys ['bear', 'hi', 'there'] >>> # suppose i want to print out the keys and values stored in the dict ... >>> for k in dict_keys: ... print k,dict[k] ... bear [3, 3, 3] hi [1, 2, 3] there [5, 4] >>>