import java.util.*;
import java.io.*;

public class SortingCollection{
	public static void main(String[] args) throws IOException{
		int n = 0;
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		System.out.print("How many elements you want to enter in the list : ");
		try{
			n = Integer.parseInt(in.readLine());
		}
		catch(NumberFormatException ne){
			System.out.println(ne.getMessage() + " is not a legal entry.");
			System.out.println("Please enter a numeric value.");
			System.exit(1);
		}
		String[] names = new String[n];
		System.out.println("Please enter some names : ");
		for(int i = 0; i < n; i++){
			names[i] = in.readLine();
		}

		List<String> list = Arrays.asList(names);
		Collections.sort(list);
		System.out.print("Elements of the list in sorted order : " + list);
	}
}
