Problem:
Sorting Three Numbers

Write a program which reads three integers, and prints them in ascending order.

Input

Three integers separated by a single space are given in a line.

Output

Print the given integers in ascending order in a line. Put a single space between two integers.

Constraints

1 ≤ the three integers ≤ 10000

Sample Input 1

3 8 1

Sample Output 1

1 3 8

Solution in JAVA (judge verdict: Accepted)

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		try {
			String input = br.readLine();
			String[] splitInput = input.split(" ");
			
			List<Integer> inputList = new ArrayList<Integer>();

			inputList.add(Integer.parseInt(splitInput[0]));
			inputList.add(Integer.parseInt(splitInput[1]));
			inputList.add(Integer.parseInt(splitInput[2]));
			
			for (int num : inputList) {
				if (!(num >= 1 && num <= 10000)){
					throw new IllegalArgumentException();
				}
			}
			
			Collections.sort(inputList);
			
			System.out.println(inputList.get(0) + " " + inputList.get(1) + " " + inputList.get(2));

		
		} catch(NumberFormatException e) {
			e.printStackTrace();
		} catch(IllegalArgumentException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}