Test cases failed

import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
String[] arr=new String[n];
for(int i=0;i<arr.length;i++) {
arr[i]=sc.next();
}
lexical_sort(arr);
display(arr);
sc.close();
}
public static void display(String[] arr) {
for(int i=0;i<arr.length;i++) {
System.out.println(arr[i]+" ");
}
}
public static void lexical_sort(String[] arr) {
for(int i=0;i<arr.length;i++) {
for(int j=i+1;j<arr.length;j++) {
if(arr[i].compareToIgnoreCase(arr[j])>0) {
String temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
}
}
my progeam run successfully but my test case failed please resove where is the error

@ketushubham098 Bro read the question properly. It is crealy mentioned that “but if a string is present completely as a prefix in another string, then string with longer length should come first. Eg bat, batman are 2 strings and the string bat is present as a prefix in Batman - then sorted order should have - Batman, bat.” and your code is not considering that condition. Your answer for the given sample test case is also wrong. The answer should be
apple
batman
bat

while your code is giving
apple
bat
batman