Klaus Mock: Sortierung

Beitrag lesen

Hallo,

while (my ($user, $anzahl) = each %anzahl) {
print "<tr>\n<td>$user</td>\n<td>$anzahl</td>\n</tr>\n";
}
.....

Jetzt möchte ich alles nach username alphabetisch sortiert haben. Setzte ich sort vor each %anzahl, so bekomme ich eine Sortierung nach $anzahl. Wie funktioniert es richtig?

Ich bevorzuge für solche Fälle die Funktion keys.
foreach $key (sort keys %hash)
  {
  print "$key = $hash{$key}\n";
  }

Grüße
  Klaus