in reply to Sorting a hash of arrays based on a particular array element.
You need the Schwartzian Transform. If you do a search or super search on sorting you will find an abundance of nodes. You could also look up the the Orcish Manouver (a pun on or cache). There is also a great paper on sorting A Fresh Look at Efficient Perl Sorting
but for simplicity go for one of the solutions below.%hash=( 1 => [ 51, 'a2'], 2 => [42, 'a1'] ); print "$_ => @{$hash{$_}}" for map substr($_,2), sort map {pack("C2", $hash{$_}[0])."$_"} keys %hash;
Cheers,
R.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sorting a hash of arrays based on a particular array element.
by merlyn (Sage) on Jul 27, 2005 at 13:37 UTC | |
|
Re^2: Sorting a hash of arrays based on a particular array element.
by salva (Canon) on Jul 27, 2005 at 13:39 UTC |