in reply to Sort xml based on attribute

While you have shown us some of your data, you haven't shown us any of your code and how it fails to produce the results you want. We cannot help you without knowing what you've done already and where your exact problem is.

Personally, I would approach the problem by either restructuring/restringifying the XML fragments to be sorted so that they sort ASCIIbetically or by using XPath queries to extract the attributes after which the fragments are to be sorted and then output the new document by stringifying their nodes.

For both approaches, XML::Twig or XML::LibXML would work, and also Jendas XML::Rules I suppose.