hi team,
My program is not sorting numbers.
can you tell me why my compare function is not working
#include
#include
#include
#include
using namespace std;
bool compare(string x,string y){
int i=0;
while(x[i]==y[i] && x[i]!=β\0β && y[i]!=β\0β)
i++;
if(x[i]==β\0β)
return 1;
else if(y[i]==β\0β)
return 0;
else if(x[i]-β0β>y[i]-β0β)
return 0;
else return 1;
}
int main(){
#ifndef ONL
freopen(βinput.txtβ,βrβ,stdin);
freopen(βoutput.txtβ,βwβ,stdout);
#endif
int t,n;
cin>>t;
while(tβ){
cin>>n;
vector arr;
for(int i=0;i<n;i++){
string temp;
cin>>temp;
arr.push_back(temp);
}
sort(arr.begin(),arr.end(),compare);
for(int i=0;i<n;i++)
cout<<arr[i];
cout<<endl;
}
return 0;
}