perlCrazy has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
I have hash structure like this :
%devLst = ("dev1" => 2001,"dev2" => 1791, "dev3" => 32000,"dev4" => 1791, "dev5" => 32000,"dev6" => 1791, "dev7" => 32000 );
where dev1 = device name and 2001 = size of device
Want to make one array where all device name (dev1...devn). Should be in ascending order by size.
My final array should look like this:
ex: my @resArr = (dev2,dev4,dev6,dev1,dev3,dev5,dev7); Any help will be appriciated.
Thanks.
I have hash structure like this :
%devLst = ("dev1" => 2001,"dev2" => 1791, "dev3" => 32000,"dev4" => 1791, "dev5" => 32000,"dev6" => 1791, "dev7" => 32000 );
where dev1 = device name and 2001 = size of device
Want to make one array where all device name (dev1...devn). Should be in ascending order by size.
My final array should look like this:
ex: my @resArr = (dev2,dev4,dev6,dev1,dev3,dev5,dev7); Any help will be appriciated.
Thanks.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Sorting of hash by value
by ikegami (Patriarch) on Jan 12, 2009 at 06:25 UTC | |
Re: Sorting of hash by value
by moritz (Cardinal) on Jan 12, 2009 at 06:23 UTC | |
Re: Sorting of hash by value
by BrowserUk (Patriarch) on Jan 12, 2009 at 06:26 UTC | |
Re: Sorting of hash by value
by wfsp (Abbot) on Jan 12, 2009 at 06:48 UTC | |
by perlCrazy (Monk) on Jan 12, 2009 at 06:50 UTC |
Back to
Seekers of Perl Wisdom