Why my solution is not working


#1

bool comp(int a,int b)
{
return to_string(a)+to_string(b)>to_string(b)+to_string(a);
}
string Solution::largestNumber(const vector &a) {

sort(a.begin(),a.end(), comp);
string ans="";
for(auto i=a.begin();i<a.end();i++)
{
    ans+=to_string(*i);
}
return ans[0]=='0'? "0" : ans;

}


#2

u cant sort a const vector A