> A dictionary stores its values based on the keys. Internally Python > sorts the keys to make the lookup meet performance expectations. > > You can not expect a dictionary to return keys in the other you added > them. If you want that, store the items as tuples in a list.
Or you can sort the keys and iterate over that: keys = dic.keys() keys.sort() # sorts in place! for key in keys.sort(): print key,dic[key] Alan G _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor