/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, OCaml, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
import java.util.*;
import java.lang.*;
class Main
{
public static void main(String args[])
{
int i,j;
Scanner sc=new Scanner(System.in);
System.out.println("enter the number of Strings that u want to compare");
int n=sc.nextInt();
String temp;
String[] names=new String[n];
System.out.println("enter the strings that u want to compare");
for(i=0;i<n;i++)
{
names[i]=sc.nextLine(); //reading strings from user
}
//loop for sort the strings
for(i=0;i<names.length;i++)
{
for(j=i+1;j<names.length;j++)
{
if((names[i].compareTo(names[j]))>0)
{
temp=names[i];
names[i]=names[j];
names[j]=temp;
}
}
}
System.out.println("the strings after sorted order");
for(i=0;i<names.length;i++)
{
System.out.println(""+names[i]);
}
}
}