in reply to Sort n Create XML

Look up the package XML::Simple;.

This allows you to read the entire XML file in a variable using XMLin

Now the easiest way to understand what has happened is to use Data::Dumper and print Dumper($xmlcontents) where $xmlcontents is what was read by XMLin.

Now just sort, and then use XMLout to print it.