in reply to calculating the mode
$counts{$_}++ for @array_of_numbers; my @sorted_array = sort { $counts{$a} <=> $counts{$b} } keys %counts;
Basically, go through the array and tally the occurances of numbers within a hash.
Finally sort the keys of the hash using a sort on the number or occurances.
Or have I missed something?
Amended: thanks to Molt ;)
--
Brother Frankus.
¤
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: calculating the mode
by Anonymous Monk on Jun 10, 2002 at 10:23 UTC | |
by frankus (Priest) on Jun 10, 2002 at 10:48 UTC |