Just another Perl shrine | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
of course, jettero posted already a very compact working solution, but I found the topic interesting enough to try that one too. In contrast to the solution already given, one could solve these problems per 'hash flipping'. This would trace down the hashes of hashes and at the end of the way would put the keys of the chain plus the value into an array. This array would then be a 'flipped hash representation'. This could then be handled simply by a loop:
(reverse sort - to get your desired order). This may be printed via:
which would print the desired output:
How would such a flippout() subroutine look like? A straightforward implementation would read like:
This seems to be something like an explicit version of jettero's code. Regards mwa In reply to Re: sorting HoH according to value
by mwah
|
|