Help finding most popular value in array
I have a list of 30 single values in an array, all 4 digit numbers.
I would like to be able to find the most popular value in this array and the number of times it occurs.
Can anyone give me a simple way of doing this?
1. Pass through the array, building another array that contains the 4 digit numbers, and as a second dimension, the number of times the 4 digit number is found.
Basically, use the 4 digit number to search your second array, if you find the 4 digit number, add 1, if you don't find it, add it as a new entry with a value of '1' in the second dimension.
2. Then pass through the second array, you simply store the 4 digit number that has the highest value.