in reply to Sorting by values doesn't work

Works for me... (ActivePerl 5.8.2):
use strict; use warnings; my %match = ( 'A' => '1', 'B' => '5', 'C' => '9', 'D' => '8', 'E' => '2', ); foreach my $k (sort { $match{$a} <=> $match{$b} } keys %match) { print "$k - $match{$k}\n"; } foreach my $word(sort byval keys %match) { print "$word - $match{$word}\n"; } sub byval { return $match{$b} <=> $match{$a}; }

And the output -
A - 1 E - 2 B - 5 D - 8 C - 9 C - 9 D - 8 B - 5 E - 2 A - 1

Can you show us more of your code because I believe the problem is related to something else in your code.