Bubble Sort Implementation
The computing gallery at Riverbend Museum has a working exhibit that puts numbers in order in front of the visitor, one comparison at a time, so that a child can watch the values crawl into place. Handing the job to a library would leave the display with nothing to show, so the exhibit's code is written out in comparisons and swaps. Your version has to work the same way: sorted() and .sort() are off limits and the ordering has to be done by hand.
Task: Print the numbers in ascending order.
Input
A single line holding between 1 and 1000 integers separated by single spaces. They may arrive in any order and may include repeats.
Output
One line holding the same numbers in ascending order, separated by single spaces.
Example:
Input:
5 2 8 1 9
Output:
1 2 5 8 9
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in