Perl 5.8.1 added hash randomisation (see
https://metacpan.org/release/JHI/perl-5.8.1/view/pod/perldelta.pod#Hash-Randomisation).
The effect is that multiple invocations of `keys %hash` return the hash keys in
different ordering, even between separate runs of the script with the same
inputs.
As a result, running the script multiple times, yielded non-identical XML
output, since the order of the mappings and application lists is different
every time.
By first sorting the hash keys for the mapping and application hashes before
iterating over them, multiple runs of the script with the same inputs result in
identical output.