in reply to Twig - sorting XML error

Use the more general sort_children, provide a subroutine that returns the TabOrder if it exists, and zero otherwise:
$element->sort_children(sub { my ($elt) = @_; my $to = $elt->first_child('TabOrde +r'); $to ? $to->text : 0 }, type => 'numeric');
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]