$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.
¤
In reply to Re: calculating the mode
by frankus
in thread calculating the mode
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |