Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
When I try the code below, it just returns a random unsorted list.foreach $k(sort {$match{$a}<=>$match{$b}} keys %match} I get an error, "Can't use "my $b" in sort comparison at D:\db\New\est +_keywords.pl line 41."
Help?foreach $word(sort byval keys %match) { if ($match{$word} < 3) {next;} print "$word\t$match{$word}\n"; } } sub byval { return $match{$b} <=> $match{$a}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sorting by values doesn't work
by blokhead (Monsignor) on Jan 28, 2004 at 23:43 UTC | |
|
Re: Sorting by values doesn't work
by ysth (Canon) on Jan 29, 2004 at 00:08 UTC | |
|
Re: Sorting by values doesn't work
by fireartist (Chaplain) on Jan 29, 2004 at 09:36 UTC | |
|
Re: Sorting by values doesn't work
by Roger (Parson) on Jan 29, 2004 at 05:18 UTC |