String compression problem test cases 2&3 are not passing

#include
#include
#include
using namespace std;
void compression(string s,int len)
{
int count=0;
sort(s.begin(),s.end());
string s1;
s1[0]=’,’;
for(int i=0;i<len;i++)
{
if(s[i]==s1[0])
{
continue;
}
else{
for(int j=0;j<len;j++)
{

        if(s[i]==s[j])
        {
            count++;
            s1[0]=s[j];
        }
    }

    cout<<s[i]<<count;
    count=0;
}
}

}
int main()
{
int len;
string s;
cin>>s;
cin.get();
len=s.length();
compression(s,len);
}

Save your code on ide.codingblocks.com and then share its link.

Consider a test case:
sskkkkkkwaerrtss

Expected Output:
s2k6w1a1e1r2t1s2

Your Output:
a1e1k6r2s4t1w1

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.