Well and the code has a major disdvantage. Its O(N*N), so it shouldn't be written at all really. :)
The standard alogithm for frequency counting uses a (hash) map and it's O(N) only. Just one scan of the input array is required. It makes a big difference for big inputs.

