in reply to Sort Hash of hashes
Result:my %sorted; for my $key (keys %bigrams) { my $hash = $bigrams{$key}; for my $secKey (sort { $hash->{$a}<=>$hash->{$b} } keys %$hash) { my $value = $hash->{$secKey} / $freqs{$key}; push( @{ $sorted{$key} }, [$secKey,$value] ); } } while ( my ( $key, $aoa ) = each %sorted ) { print "$key\n"; for my $ary ( @$aoa ) { print "\t$ary->[0] => $ary->[1]\n"; } }
like VBP => 0.0882352941176471 VB => 0.0882352941176471 IN => 0.823529411764706 kind JJ => 0.2 NN => 0.8 capped VBN => 0.333333333333333 JJ => 0.666666666666667 successful JJ => 1 distribution NN => 1
|
|---|