in reply to Sorting by Hash Slice
As tim says, without a more detailed problem description, it seems that the extra level of nesting in %bighash (set1, set2, etc.) is unnecessary.# 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"; }
|
|---|