in reply to Finding most popular order in a multidimensional associative array
use strict; my %hash = ( Key1 => [qw(a b b b a a c d b d b)], Key2 => [qw(c a b a b d c c d d d e f)], ); for (sort keys %hash) { my %counted; $counted{$_}++ for @{$hash{$_}}; print "$_:\n"; for (sort { $counted{$b} <=> $counted{$a} } keys %counted) { print "\t$_ = $counted{$_}\n"; } }
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) Re: Finding most popular order in a multidimensional associative array
by Anonymous Monk on Aug 05, 2002 at 00:48 UTC | |
by jeffa (Bishop) on Aug 05, 2002 at 01:05 UTC | |
by Anonymous Monk on Aug 05, 2002 at 01:12 UTC |