| « Yum : Howto download source packages | Encode/decode SMTP AUTH username/passwords » |
Here's an alpha sort of the values of the associative array named "myarray":
foreach my $key (sort {$myarray{$a} cmp $myarray{$b}} keys %myarray) {
print "$key : " . $myarray{$key} . "\n";
};
And here's the same sort numerically:
foreach my $key (sort {$myarray{$a} <=> $myarray{$b}} keys %myarray) {
print "$key : " . $myarray{$key} . "\n";
};
And if you want numeric descending:
foreach my $key (sort {$myarray{$b} <=> $myarray{$a}} keys %myarray) {
print "$key : " . $myarray{$key} . "\n";
};