|No such thing as a small change|
Re: sorting HoH according to valueby mwah (Hermit)
|on May 27, 2008 at 14:02 UTC||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.