I would like to print a python dictionary to a file using PrettyPrinter (for human readability) but have the dictionary be sorted by key in the output file to further improv
You could transform this dict a little to ensure that (as dicts aren't kept sorted internally), e.g.
pprint([(key, mydict[key]) for key in sorted(mydict.keys())])