Sort not working

#include
#include
#include
#include
using namespace std;

bool compare(int a, int b)
{
stringstream ss;
ss << a;
string s1, s2;
ss >> s1;
ss << b;
ss >> s2;

string ab = s1.append(s2);
string ba = s2.append(s1);

return ab.compare(ba) > 0 ? true : false;

}
int main()
{
int t, i, j, n, arr[100];
cin >> t;
for (i = 0; i < t; i++)
{
cin >> n;
for (j = 0; j < n; j++)
{
cin >> arr[j];
}
sort(arr, arr+n, compare);
for (j = 0; j < n; j++)
{
cout << arr[j];
}
}
return 0;
}

I think conversion of int to string is casuing some problems . … ? What is the problem with my code

string ab = s1.append(s2);
string ba = s2.append(s1);

these statements are wrong

suppose s1 is 38 and s2 is 22
then ab will be 3822 but also now s1 changes to 3822 because changes occur on s1
s1 is appended with s2

Correct way to do

	string ab = s1 + s2;
	string ba = s2 + s1;

Yes , there is one mistake in that also
you have to clear the stream before using it second time
because some whitespace will be stuck in it

also you have to put endl after each testcases

Modified Code

Now it passes all testcases