Sorting an array in ascending order
Java
Easy
sorting
Task «Sorting an array in ascending order»
Write a program that reads an integer n, then n integers, and outputs them in ascending order. Use bubble sort or built-in Java tools. The numbers can be negative and positive.
Input Format
The first line contains an integer n (1 ≤ n ≤ 1000). The second line contains n integers separated by spaces.
Output Format
One line containing n integers, sorted in ascending order, separated by spaces.
Examples
Example 1
INPUT
5
3 1 4 1 5
OUTPUT
1 1 3 4 5
Example 2
INPUT
2
1 3 5
2 4 6
OUTPUT
1 3 5
Example 3
INPUT
3
-2 0 7
OUTPUT
-2 0 7
Example 4
INPUT
5
3 1 4 1 5
OUTPUT
1 1 3 4 5
Example 5
INPUT
3
10 20
15 25
5 30
OUTPUT
10 20
main.java