in reply to sorting an array of hashes by the value of the keys
use Data::Dumper; my @aoh = ({doc1=>2345}, {doc2=>1234}, {doc3=>5678}, {doc4=>4567}); my @sorted_aoh = sort { (%$a)[1] <=> (%$b)[1] } @aoh; print Dumper \@sorted_aoh; __output__ $VAR1 = [ { 'doc2' => 1234 }, { 'doc1' => 2345 }, { 'doc4' => 4567 }, { 'doc3' => 5678 } ];
_________
broquaint
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: sorting an array of hashes by the value of the keys
by diotalevi (Canon) on Jun 19, 2003 at 15:34 UTC |