Q:

How to prevent XMLSerializer.serializeToString() from re-ordering attributes?

I'm using jQuery to load arbitrary XML strings (fragments of a larger document) into the browser DOM and manipulate them, then using XMLSerializer to load them back to strings and send them back to the server, where they are processed (by python and lxml) and re-integrated into a full XML document.
The XML starts and ends in a git repository. I've found that the attributes on elements processed by XMLSerializer are reversed in order, resulting in spurious changes showing up in my repository, like so:
- <literal><token kind="w" id="en-us-esv-xeaugcbzgo">sent</token><token kind="s" id="en-us-esv-xeaugcbzgw"> </token></literal>
+ <literal><token id="en-us-esv-xeaugcbzgo" kind="w">sent</token><token id="en-us-esv-xeaugcbzgw" kind="s"> </token></literal>

This isn't a bug with any of the tools I'm using. Of course, the order of attributes on an xml element aren't supposed to matter. But, because git is a line-oriented SCM, these spurious and insignificant changes will distract from the actual substantive changes that I want to track.
The Question: Is there a way to keep the serializer from re-ordering my attributes? Alternately, do any tools exist to specify/constrain the ordering of attributes? 
Edited above for clarity: I am aware that, according to the XML Specification, "the order of attribute specifications in a start-tag or empty-element tag is not significant": http://www.w3.org/TR/REC-xml/#sec-starttags. Suffice it to say, the ordering of attributes is significant to me. :)

A:

I've taken the direction @Tomalak suggested and am "fixing" the order server-side. Thankfully, the original order was alphabetical, and the order produced by XMLSerializer is reverse alphabetical. My server-side XML tool, lxml, maintains document attribute order, so reversing the order is simple:
xmls = json.loads(self.data['xmls'])
out = []
for xml in xmls:
    # DOM adds an XHTML namespace... silly DOM.
    xml = xml.replace('xmlns="http://www.w3.org/1999/xhtml"', '')
    tree = ET.fromstring(xml)
    for el in tree.xpath('//*'):
        attrs = dict(el.attrib)
        keys = el.attrib.keys()  # el.attrib preserves attribute order
        keys.reverse()  # But the browser DOM has reversed that order.
        # Put them back in the order we want.
        el.attrib.clear()
        for k in keys:
            el.attrib[k] = attrs[k]
    out.append(ET.tostring(tree, encoding=unicode))

My line-based diffs are useful again!

