Question
Sort the Trio
You are given n integers, each provided one per line.
Each integer will be either 0, 1, or 2.

Your task is to rearrange and print all the numbers in the following order:
-First, print all the 0s.
-Then, print all the 1s.
-Finally, print all the 2s.

In simple words, Print all the numbers in ascending order (0s first, 1s next, 2s last).
 
Input
The first line contains an integer n, the number of integers.
The next n lines each contain one integer (0, 1, or 2).
Output
Print all the numbers separated by space in the order: 0s, then 1s, then 2s.
Example
Example 1:
Input:
6
0
2
1
2
0
1

Output:
0 0 1 1 2 2

Example 2:
Input:
5
2
0
1
2
0

Output:
0 0 1 2 2

Online