Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
foreach $word(@words){ $Counter = $Counter+1; #print("$word\n"); } $sentence_count{($Counter)} = $sentence_count{($Counter)}sort by_num ( +keys (%sentence_count)); while (($sentence_count,$word_count) = each(%sentence_count)) { print ("\nThere are $word_count sentences of $sentence_count words\n") +; } sub by_num { if ($b < $a) { return -1; } elsif ($a == $b){ return 0; } elsif ($b > $a){ return 1; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) Re: hash sorting problems
by jeffa (Bishop) on Apr 20, 2001 at 22:06 UTC | |
|
Re: hash sorting problems
by satchboost (Scribe) on Apr 20, 2001 at 21:42 UTC | |
by little (Curate) on Apr 20, 2001 at 22:20 UTC | |
|
Re: hash sorting problems
by Sprad (Hermit) on Apr 20, 2001 at 21:54 UTC | |
|
Re: hash sorting problems
by Beatnik (Parson) on Apr 21, 2001 at 02:40 UTC |