String sort doubt

Notsure what is wrong regarding the code failed for 1 testcase

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scan =new Scanner(System.in);

	int n=scan.nextInt();
	String[]array=new String[n];
	for(int i=0;i<array.length&&i<=1000;i++)
	{
		
		 array[i]=scan.next();
		}
	int v=0;
	int w=0;
String[] arr=	sortstrings(v,w,array);

for(String val:arr)
{
	System.out.println(val);
}
}





public static String[] sortstrings(int i,int j,String[] array)
{
	for(i=0;i<array.length-1;i++)
	
	{
		for(j=i+1;j<array.length;j++)
		{
			
			if(array[i].charAt(0)>array[j].charAt(0))
					{
				
				String temp=array[i];
				 array[i]=array[j];
				 array[j]=temp;
				
					}
			else if(array[i].charAt(0)== array[j].charAt(0))
			{
				if(array[i].length()<array[j].length())
				{
					String temp=array[i];
					 array[i]=array[j];
					 array[j]=temp;
				}
			}
			
		}
	}

return array;
}

}

your condition in sorting is not correct…take an example)
apple and ape

given two strings s1 and s2 you have to loop over 2 strings character by character and then write your logic for sorting

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.