Form Biggest Number

Running code Fine But Test not passes

public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();

while(t!=0){
int n = sc.nextInt();
String[] A = new String[n];
for(int i=0;i<n;i++) {
A[i]=sc.next();
}
for(int i=0;i<n-1;i++){
for(int j=0;j<n-1-i;j++){
if(compare(A[j],A[j+1])==false){
swap(A,j,j+1);
}
}
}
for(int i=0;i<n;i++){
System.out.print(A[i]);
}
t–;
}
}
public static void swap(String arr[],int a,int b){
String temp =arr[a];
arr[a]=arr[b];
arr[b]=temp;
}
public static boolean compare(String a,String b){
a = a+b;
b = b+a;
if(a.compareTo(b)>0){
return true;
}
else
return false;
}}

see test cases like
51
19867 22603 24383 19913 20137 8831 12236 2277 26700 244 28053 12886 30932 2313 1929 12320 30148 9097 10074 6397 8068 16779 8914 12378 7510 22678 5994 25507 5515 27145 25625 11456 5623 6586 30058 32224 24738 6110 6097 6773 28864 25129 17471 383 19428 8246 6900 19726 29552 7976 149
you are getting TLE

just create a compare function for two numbers X and Y, compare two numbers XY (Y appended at the end of X) and YX (X appended at the end of Y). If XY is larger, then X should come before Y in output, else Y should come before.

see this: