in reply to question re: hash sorting

The code as it stands doesn't do anything. It seems that the author wanted to sort the %tallies hash, but is it doesn't quite have enough information there to get the job done (and I'm not sure why those my statements are there). It should be something like:

my @sorted_data = sort { $tallies{$a} <=> $tallies{$b} } keys %tallies +;

See also sort.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

Note: All code is untested, unless otherwise stated

Replies are listed 'Best First'.
Re: Re: question re: hash sorting
by Grygonos (Chaplain) on Aug 25, 2003 at 19:44 UTC
    right .. i put it out of context it was in a foreach.
    foreach my $key (*funky sort algo*)
    to return the sorted list as the list to do the foreach over.

    RTFM to the rescue... sorry guys..