Sort keys in dictionaries before exporting