When parsing an xml file into a Python ElementTree the attributes' order is mixed up because Python stores the attributes in a dictionary.
How can I change the order of the attributes in the dictionary?
You can not change the order of attributes internally in the dictionary.  This is impossible unless you do some fancy hacking.
The solution therefore, is to manually access the attributes in the order you want them, or create a list of the keys/items and sort that the way you want.
How to order xml element attributes in Python?