Output the headers sorted alphabetically

I'm an idiot for relying on the order of the dictionary items. Sorting the
fields before outputting them seems to be the quick fix for this mess.