...my %articles;foreach my $articleNodeElem (@$articleNodeArr) { my $dateVal = fixdate($articleNodeElem->getAttribute('Date')); my $articleDCR = ...; # presumably you can get the vpath to the article DCR yourself push (@{$article{$dateVal}}, $parser->parsefile($articleDCR));}foreach my $date (sort keys %articles) { foreach my $art (sort { somefunc } @{$articles{$date}}) { # output the relevant information from $art as an XML:OM object }}...sub somefuc { return $a->getNodeValue(...) cmp $b->getNodeValue(...);}sub fixdate { my $in = shift; if ($in =~ m|^(\d{2})/(\d{2})/(\d{4})|) { return "$3$1$2"; } return $in; # unmodified}