import java.util.*;
class sort
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String s[] = new String[sc.nextInt()];
        String temp;
        sc.nextLine();
        for(int i=0;i<s.length;i++)
        {
            s[i]=sc.nextLine();
        }
        for(int i=0;i<s.length;i++)
        {
            for(int j=i+1;j<s.length;j++)
            {
                if(s[i].compareTo(s[j])>0)
                {
                    temp=s[i];
                    s[i]=s[j];
                    s[j]=temp;
                }
            }
        }
        System.out.print("Names in Sorted Order:");
        for(int i=0;i<s.length;i++)
        {
            System.out.print(s[i]);
            if(i<s.length-1)
            {
                System.out.print(",");
            }
        }
        System.out.println();
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: