in reply to sorting an array of hashes by the value of the keys
Yet another way to do it...
my @array = ({doc1=>2345}, {doc2=>1234}, {doc3=>5678}, {doc4=>4567}); my %hash = map { %{$_} } @array; my @sorted = sort { $hash{$a} <=> $hash{$b} } keys %hash; print "@sorted\n";
Update: Removed each from my %hash = map { each %{$_} } @array;.
|
|---|