in reply to Sorting a hash of arrays based on a particular array element.

I'm not sure what you want in your result - either the first item in the array reference, or the array references being sorted by the first value. I'm going for the latter, but I'm sure that you can modify as required:

use Sort::Key qw(nkeysort); use Data::Dumper; my %hash = ( 1 => [ 51, 'a2'], 2 => [42, 'a1'] ); my @res = nkeysort { $_->[0]} (values %hash); print Dumper(\@res);
giving
$VAR1 = [ [ 42, 'a1' ], [ 51, 'a2' ] ];