arunhorne has asked for the wisdom of the Perl Monks concerning the following question:
I have a hash in which each mapping references an array. Anyone know how I could sort the hash based on the size of the referenced arrays?
Thus: key0 -> (f, a) key1 -> (a, b, c, d, e) key2 -> (g) key3 -> (h, i, j)
From this example I want to generate the output
key2 -> 1 key0 -> 2 key3 -> 3 key1 -> 5
I.e. The keys are sorted in ascending order based on the size of their referenced arrays (and I want to print the above keys/sizes to a text file).
Best wishes, Arun
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sort Hash by Size of the Arrays it References
by broquaint (Abbot) on May 02, 2002 at 10:09 UTC | |
by grinder (Bishop) on May 02, 2002 at 13:41 UTC |