foreach $junk (sort {$b->{'count'} cmp $a->{'count'} or $b->{'type'} cmp $a->{'type'}} @data) { print "$junk->{'count'} --> $junk->{'type'} --> $junk->{'a_point'} -> $junk->{'z_point'} --> $junk->{'error'}\n"; }