# selected stores my @st= ('STORE2','STORE3','STORE5'); # list of stores (doesn't keep duplicates) my %stores= map { %$_ } values %bighash; foreach my $store ( sort { $stores{$b}[0] <=> $stores{$a}[0] } @st ) { my $products= $stores{$store}; my $earned = shift @$products; print "STORE: $store EARNING: $earned\n"; foreach my $product ( @$products ) { print join( "," => @$product ), "\n"; } print "\n"; }