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

Update

As merlyn points out below you do not need Schwartzian/Orcish as your sort keys are already there. If you have a large amount of data to sort you may get some efficiency gain from the "Packed Default" method in the Guttman & Rosler paper A Fresh Look at Efficient Perl Sorting Here is an example of the Packed Default method ...
%hash=( 1 => [ 51, 'a2'], 2 => [42, 'a1'] ); print "$_ => @{$hash{$_}}" for map substr($_,2), sort map {pack("C2", $hash{$_}[0])."$_"} keys %hash;
but for simplicity go for one of the solutions below.

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!

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
    not too long ago I released Sort::Key on CPAN, it outperforms the Schwartzian Transform and the methods described on the cited paper in almost any case and is easier to use.