I have an array which is populated based on the values pulled in from an api call. the array would be having values like this
["9777", "9777", "2.4", "9777", "2.4", "2.4", "9777", "2.4", "2.4", "9777", "9777", "2.4", "2.4", "2.4"]
What I am trying to do is get the count of the occurences of each item in the array and sort it descending based on the count.
I did this which I got it from stackoverflow:
data.forEach(function (x) {
counts[x] = (counts[x] || 0) + 1;
});
It works, but it gives weird results which makes it difficult to extract the value from the result.
here are the results:
