#!/bin/perl -w use strict; use XML::Twig; my $twig= XML::Twig->new(pretty_print=>'indented'); #$twig->parsefile("OpsbankII-im1.xml"); $twig->parse(\*DATA); my $root=$twig->root; $root->first_child->sort_children_on_att("type"); sort_my_kids($root); $twig->print; #---------- sub sort_my_kids{ my $me = shift; $me->sort_children_on_value; foreach my $kid($me->children){ sort_my_kids($kid); # Recursive } } __DATA__ algorithm colon diverticulosis surgery disease severity human recurrent disease review sigmoidectomy surgical technique treatment indication 2715 2746 DNA binding protein endogenous compound DNA polymerase endogenous compound initiation factor endogenous compound plasmid DNA endogenous compound animal cell article chromatin DNA replication DNA replication origin DNA supercoiling egg nonhuman plasmid Xenopus laevis Animalia Eukaryota Xenopus laevis 1312 37217-33-7 DNA polymerase acetonitrile derivative benzene derivative cyclohexane derivative lactic acid derivative lactone derivative organic solvent poly(3 hydroxybutyric acid) endogenous compound poly(3 hydroxybutyric acid) depolymerase endogenous compound polyhydroxyalkanoic acid unclassified drug article catalysis enzyme activity esterification hydrolysis nonhuman polymerization Pseudomonas pseudomonas lemoignei reaction analysis stereochemistry synthesis 1605 26063-00-3 poly(3 hydroxybutyric acid) axillary lymph node breast carcinoma diagnosis cancer staging cancer surgery human lymph node dissection lymph node metastasis complication surgery priority journal prognosis review treatment outcome treatment planning 1306 2730 aged article electrode female heart atrium heart pacing heart ventricle human implantation longevity major clinical study male medical instrumentation survival treatment indication 1314 2705 Intermedics ThinLine bipolar pacing lead Intermedics C reactive protein endogenous compound fibrinogen endogenous compound heat shock protein 60 endogenous compound high density lipoprotein cholesterol endogenous compound roxithromycin drug therapy triacylglycerol endogenous compound angiography atherosclerosis etiology bacterium isolation chlamydiasis drug therapy Chlamydophila pneumoniae controlled study disease association endothelium injury diagnosis human human cell human tissue immunoregulation pathogenesis priority journal review risk factor seroepidemiology 2705 9001-32-5 fibrinogen 9007-41-4 C reactive protein 80214-83-1 roxithromycin