String Sorting using java Program

String sorting

public class Stringsorting

{

public static void main(String args[])

{

String str=”sirishe”,str1=”sirisha”;

char s[]=str.toCharArray();

char s1[]=str1.toCharArray();

int a=’0′,j=0;

for(int i=s.length-1;i>=0;i–)

{

if(((int)s[i])>((int)s1[i]))

{

j=1;

}

else

{
j=0;
}

}

if(j==1)

{

System.out.println(str+”t”+str1);

}
else
System.out.println(str1+”t”+str);
}

}

Output:  sirisha sirishe

Leave a Reply