Few Question About Program

Basically that is the task i am trying to accomplish
Write a program that reads a token stream from standard input,
picking out zipcodes which are assumed to be 5 character strings preceded by the token "zip:".
The program prints the top 10 most frequently occuring zipcodes and their frequency, in descending order of frequency.
Each line should have the form: zipcode frequency
In the case where two lines have the same frequency, the zipcode with the lower number should come first (so 11210 comes before 11217)
If there are FEWER than 10 entries, then they all should be printed, in the sorted fashion described above.
What i have so far is this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
bool findFunc(string zipArray[], int size, string zip){
int i=0;
string str;
str=zip;
for (i=0;i<size;i++){
    if (zipArray[i]==str){
        cout<<"Found"<<endl;
        return true;
        break;
    }
}
return false;
}
int arrayChange(int integerArray[],int size, string zipArray[]){
int i;
for (i=0;i<size;i++){
   stringstream ss(zipArray[i]);
   ss >> integerArray[i];
}
return integerArray[i];
}
void bubblesort (int integerArray[], int size){
int temp;
bool swapped;
do {
    swapped=false;
    for (int i=size-1;i>=0;i--)
        if (integerArray[i]>integerArray[i+1]){
            temp=integerArray[i];
            integerArray[i]=integerArray[i+1];
            integerArray[i+1]=temp;
            swapped=true;
        }
    }
while (swapped);
return;
}
int frequencyCount(int integerArray[], int size){
int freq;

int newArray[size][1];
int last=integerArray[0];
for (int i=1;i<size;i++){
for (int j=1;j<size;j++){

        if (integerArray[i]==last)
        {
         newArray[i][j];
         freq++;
        }
        else {
        cout <<"   " << integerArray[i-1] << " " << freq << endl;
            last = integerArray[i];
            freq = 1;
        }
}
return 0;
}
}

int main (){
string previousToken=" ", token;
string arrayTokens[10000];
int integerArray[10000];
int i=0;
int j=0;
int arraySize=0;
int freq;
cin>>token;
while(!cin.fail()){
    if (token.length()==5 && previousToken=="zip:"){
        arrayTokens[i]=token;
        i++;
        arraySize++;
    }
    previousToken=token;
    cin>>token;
}
arrayChange(integerArray,arraySize,arrayTokens);
bubblesort (integerArray,arraySize);
frequencyCount(integerArray,arraySize);

for (i=0;i<arraySize;i++){
        if (integerArray[i]!=integerArray[i+1]){
    cout<<"zip code:"<< integerArray[i]<<"frequency is:"<<freq<<endl;
        }
}
findFunc(arrayTokens,arraySize, "92130");
return 0;
}


My question is how finish the last part how can i sort something by frequency of the array. I was told i might use struct, and i know the logic for it, however, i just cant figure out how to present it in code. Thanks any advice is appreciated.
Topic archived. No new replies allowed.