sorting by hash value

[email protected] (allan) Mon, 23 Sep 2002 19:44:26 +0200
Newsgroups perl.macperl.anyperl
Message-ID <[email protected]>
hi

is it possible to sort by the values in a hash if those values might
be identical ?
please try example below whcih will indeed sort the way i want, but
will (obviously) discard duplicate keys in my reverse hash;

anyone have a good idea for this ?

../allan
_________

%test = (
    abc => 1230,
    def => 456,
    cbs => 456,
    agr => 111,
);

my %reverse_test = reverse %test;
my @sorted_keys = sort { $a <=> $b } keys %reverse_test;

foreach my $key (@sorted_keys) {
    print "$key => $reverse_test{$key}\n" 
}

__END__