A specific sorting algorithm is as follows:
You iterate down the list of elements checking if they're in increasing order. Any element which is out of order is eliminated. At the end you have a sorted list.
Can you implement it?
Input Specifications
The first line will contain an integer .
The next lines will contain an integer , integers of a list that you are to operate Stalin Sort
on.
Sample Input 1
7
1
4
3
2
5
5
2
Sample Output 1
1
4
5
5
Sample Explanation
The output is 1 4 5 5
because Stalin will walk from 1 to 4, 4 to 3, kicking 3 out, and so on.
Comments