Challenges : string sort

what is wrong in my code?
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
String temp;
String []I = new String[n];
int i,j;
for(i = 0 ; i<n ; i++)
{I[i] = s.nextLine();}
for(i = 0 ; i<n ; i++)
{for(j = i+1 ; j<n ; j++)
{

		if (I[i].compareTo(I[j])>0)
	{ temp = I[i];
	I[i]=I[j];
	I[j]=temp;}
}}
	for(i=0 ; i<n ; i++)
	{System.out.println(I[i]);}

}

}

Question says if a string is a prefix of another string and is shorter in length, it should be placed later in the result array. Butt your code uses compare to function which doesn’t utilize this fact. compare to places the shorter string first in such cases.