in reply to sorting hash keys

sort keys { $a <=> $b } %results

read sort.

Update:: Correction below.


holli, /regexed monk/

Replies are listed 'Best First'.
Re^2: sorting hash keys
by Anonymous Monk on May 28, 2005 at 19:43 UTC
    Hi

    Thanks for your code but I can't get it to work.

    foreach my $key (sort keys { $a <=> $b } %results) { print MAIL "$key) $results{$key}\n"; }
    Gives me the error Type of arg 1 to keys must be hash (not modulus (%)) at test.pl line 509, near "results) " Bareword "results" not allowed while "strict subs" in use at test.pl line 508. Execution of test.pl aborted due to compilation errors.
      ah, sorry. I'm tired. That should of course be
      foreach my $key (sort { $a <=> $b } keys %results) { print "$key) $results{$key}\n"; }
      my bad.


      holli, /regexed monk/