Use a second array to keep track of the frequency of each value with the indexof(value) expression.
For each element in originArray
If frequencyArray.indexof(originArray.CurValue)=-1 (doesn't exist), frequencyArray Push front originArray.CurValue, set value at 0,1 to 1.
Else set value at frequencyArray.indexof(originArray.CurValue), 1 to frequencyArray.At(frequencyArray.indexof(originArray.CurValue), 1) + 1