Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
$hash_value = { '75.34.42.17511726663' => { '2005' => [ '11.5', '363,8 +42' ], '1995' => [ '', '200,000' ], '2004' => [ '9.2', '326,345' ], ' +2001' => [ '6.7', '263,645' ], '1995' => ['','200,000'],'1997' => [ ' +2.6', '212,118' ], '1998' => [ '3.7', '219,980' ], '2002' => [ '7.6', + '283,665' ], '2006' => [ '9.4', '398,148' ], '2000' => [ '7.7', '247 +,015' ], '1996' => [ '3.3', '206,680' ], '1999' => [ '4.2', '229,281' + ], '2003' => [ '5.4', '298,857' ] } }; # To sort year from the hash - working properly @year= sort {$a cmp $b} keys(%{$hash_value->{'75.34.42.17511726663'}}) +; # To build new structure - year ascending order format. It's not worki +ng $hash_result = {}; foreach $key (@year) { $hash_result->{'75.34.42.17511726663'}->{$key} = $hash_value->{'75 +.34.42.17511726663'}->{$key}; } Is there anyother method to sort using same hash name?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: problem while sorting hash
by davorg (Chancellor) on Mar 20, 2007 at 16:46 UTC | |
by Limbic~Region (Chancellor) on Mar 20, 2007 at 22:11 UTC | |
| |
|
Re: problem while sorting hash
by wfsp (Abbot) on Mar 20, 2007 at 17:11 UTC | |
by Anonymous Monk on Mar 21, 2007 at 03:41 UTC | |
|
Re: problem while sorting hash
by TGI (Parson) on Mar 20, 2007 at 17:22 UTC | |
by Anonymous Monk on Mar 21, 2007 at 03:42 UTC |