I have a map containing the following values:
index frequency
65 1
67 5
47 3
In here i want to sort them by frequency in ascending order and print them... Here's my code regarding to this problem:
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
while(getline(cin,s))
{
map<int,int>m;
map<int,int>::iterator it;
for(int i=0; i<s.size(); i++)
m[s[i]]++;
for(it=m.begin(); it!=m.end(); it++)
cout<<it->first<<" "<<it->second<<endl;
}
return 0;
}