Leser: 20
1
2
3
4
5
my %myHash = ("A" => 215, "B"=> 10, "C" => 345, "D" => 30, "E"=>150);
foreach my $key (sort { $myHash{$b} <=> $myHash{$a}} keys %myHash){
print "$key - $myHash{$key}\n";
}
my $myHashRef = {"A" => 215, "B"=> 10, "C" => 345, "D" => 30, "E"=>150};
(sort {$myHashRef->{$a} <=> $myHashRef->{$b}} keys %myHashRef)
2009-12-29T11:13:57 biancaNur ein Versuch, bin da auch nicht so standfest:
Code (perl): (dl )(sort {$myHashRef->{$a} <=> $myHashRef->{$b}} keys %myHashRef)
Edit: Tausend mal gebastelt und umgestellt :))
1
2
3
4
my $myHashRef = {"A" => 215, "B"=> 10, "C" => 345, "D" => 30, "E"=>150};
foreach my $key (sort { $myHashRef->{$b} <=> $myHashRef->{$a} } keys %$myHashRef){
print "y $key - $myHashRef->{$key}\n";
}