Write a program that sorts any given list of integers, that is, puts them in ascending order.
Input will consist of several lines each with a list of integers separated by space. The list will not be longer than 100 elements and each element is between 0 and 1000 (inclusive).
For each line of input you should produce a line of output with the same integers in non-descending order, i.e. ascending order.
3 2 1
2 1 3 4
60 12 360 1080
1 2 3
1 2 3 4
12 60 360 1080
In this exercise, your program does not need to have optimal performance. Using bubble sort, insertion sort or selection sort should be enough to achieve a full score. Expected runtime performance is O(n²) or less.
try first: max-subarray
try next: file-write
Copyright © 2020-2022 Rudy Matela
This text is available under the CC BY-SA 4.0 license.
Originally available on cscx.org/sorting