http://www.perlmonks.org?node_id=982273


in reply to Re^2: sorting hash by a certain value (that it is in an array)
in thread sorting hash by a certain value (that it is in an array)

Perhaps you could use Tie::IxHash?
my %unordered=(...); tie my %ordered, "Tie::IxHash"; for my $key (sort {$unordered{$a}[1] cmp $unordered{$b}[1]} keys %$ +unordered) { $ordered{$key}=$unordered->{$key}; };