I would like to sort the array, increasing the frequency order. For example, if I had an array
int arr[] = { 3, 3, 10, 2, 5, 10, 10, 2, 2, 2 };
or another array will have the following sequence:
int arr[] = {5, 3, 3, 10, 10, 10, 2, 2, 2, 2};
However, I cannot use hashing or maps - I can only use arrays. What I was thinking about is sorting the array using the quick sort algorithm, scanning the sorted array and doing the count in 2d array, so for each element there is an account associated with it, and then sort by count. If the two counts match, then I would just print out the one who first had a lower value. I am having trouble completing the last two steps. I'm not sure how to βmatchβ the score to the index in the 2d array, and I'm not sure how to sort the 2d array by count. Can anyone help me out? Thanks!
source share