use Data::Dumper;
@arr = (
{
'10' => '5',
},
{
'30' => '1',
},
{
'20' => '3',
},
);
@arr_sorted = sort { (values(%$b))[0] <=> (values(%$a))[0] } @arr;
Get a list of hash keys sorted by value:
@sorted_keys = sort { $hash{$a} cmp $hash{$b} } keys %hash;
print Dumper( @arr_sorted );
No comments:
Post a Comment