the comparison function is called by qsort() -- your program should not call it directly. The two parameters are pointers into the array that you want sorted, the comparison function has no clue about which two elements of the array because its only purpose is to tell qsort whether p1 is less than, equal to, or greater than the second parameter p2. There is no way that the comparison function will find a global array of frequencies of any use.
Considering your problem, you might want to write your own custom sort algorithm so that you can take advantage of indirect sort, sort one array without disturbing the order of the second. Using your previous example of item and frequency arrays, frequency can be sorted indirectly by sorting item. Using bubble sort algorithm (you will want a better algorithm), it might look like this
you can easily find source code for lots of other better sort algorithms. Just plug one into your program and modify the comparisons to be similar to above.
void sort(int item, int itemsize, int frequency, int freqsize)
for(int i = 0; i < itemsize-1; i++)
for(int j = i+1, j < itemsize; j++)
if( frequency[ item[i] ] < frequency [ item[j] ] )
// swap item array elements
int temp = item[i];
item[i] = item[j];
item[j] = temp;
// display all the elemenets of frequency
for(i = 0; i < itemsize; i++)