I have an input XML document:
Input XML
Saxon 9.5 (PE or higher) provides a serialization option saxon:attribute-order which allows you to control the attribute order generated by the serializer. Although attribute order should not make any difference to any sane receiving application, consistent ordering can improve the human readability of the XML, and since human readability was one of the objectives of XML, I thought this was a reasonable feature to add.