bragafra has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I have a complex hash of hash, and i want to sort by keys..
I put here a simplified example...

$fruit{apple}{weight}=100;
$fruit{apple}{color}="red";
$fruit{lemon}{weight}=190;
$fruit{lemon}{color}="yellow";
$fruit{grapes}{weight}=40;
$fruit{grapes}{color}="blue";

I want to obtain something like (sorted by weight ascending...)
@sortedkeys=("grapes","apple","lemon")

Which is the best way in your opinion ?

Thank you

Replies are listed 'Best First'.
Re: sorting hash of hash by values
by Corion (Patriarch) on Mar 30, 2010 at 13:30 UTC
        Thank you :)