<gsnedders> (html5lib.serialize(my_document, alphabeticize_attributes=True) should work as an API basically)