直接用map自带的排序
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
int main(){
string str;
map<char, int> mp;
cin >> str;
for(auto c : str) mp[c]++;
for(auto it: mp) cout<<it.first<<":"<<it.second<<endl;
return 0;
}