in reply to Use of uninitialized value in string comparison (cmp)
$root->first_child->sort_children_on_att("type");
This line generates the warning - maybe XML::Twig has a problem with sorting if only one child node is present?