Getting wrong on test :[3, 30], where no of test cases 1 and number of entries is 2

The code goes here:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool cmp(ll a, ll b){
string s1 = to_string(a) + to_string(b);
string s2 = to_string(b) + to_string(a);
//cout << s1 << " " << s2 << “\n”;
int n = s1.length();
for(int i = 0; i < n; i++){
if(int(s1[i] - ‘0’) > int(s2[i] - ‘0’)){
return int(s1[i] - ‘0’) > int(s2[i] - ‘0’);
}
else if(int(s1[i] - ‘0’) < int(s2[i] - ‘0’)){
return int(s1[i] - ‘0’) < int(s2[i] - ‘0’);
}

    }
    return true;

}
int main() {
ll t;
cin >> t;
while(t–){
ll n;
cin >> n;
vector v;
for(ll i = 0; i < n; i++){
ll x;
cin >> x;
v.push_back(x);
}
sort(v.begin(), v.end(), cmp);
string s = “”;
for(ll i = 0; i < n; i++){
s = s + to_string(v[i]);
}
cout << s << “\n”;
}
return 0;
}

when comparing two strings dont use that method instead use s1+s2 < s2+s1. It would work. Also dont take integer values as input. Take string inputs

Have a look at this code for reference.

Can you please elaborate the reason why my method is wrong, means if i convert the input to string, and than compare the strings manually, there should not be an error.

The input can be really big values so better take string input.

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.

My doubt is not about large input.
My doubt is: "Why do we get unexpected answer when we compare the bigger and smaller string number through checking every index of the strings manually(i.e. for(int i = 0; i<n; i++) if(s1[i]) >s2[i])).
But we get correct answer using string compare function( i.e. s1.compare(s2))

Can you please clarify my doubt?

I already told you that
Let’s take an example: 9 990
If you compare two numbers that answer will be 9909. But if you compare s1+s2. Then ans will be 9990