I am trying to print out the members of a multidimensional associative array according to their popularity. Assume, for example, that my array is built using the following data:
$my_associative_array{"Key1"}=[qw(a b b b a a c d b d b)];
$my_associative_array{"Key2"}=[qw(c a b a b d c c d d d e f)];
I am trying to get output such as follows:
Key1:
b = 5
a = 3
d = 2
c = 1
Key2:
d = 4
c = 3
a = 2
b = 2
e = 1
f = 1
As you can see, the output is sorted according to the number of times the data appears in the array. I'm sure this is probably easy for some of you perl guru's out there, but I sure am strugling with it. Any help is most appreciated. And by the way, what a wonderful site!
edited: Sat Aug 3 02:30:33 2002 by jeffa - code tags
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.