All problems

Selection Sort Implementation

mediumPythonSorting

Meridian Freight loads pallets onto a truck lightest first. The crew fills one slot at a time: they look over everything still on the dock, pick the lightest pallet left, and drop it into the next slot. Dispatch has to print the loading order before the crew starts, and it has to be produced by that same pick-the-smallest-each-time routine rather than by Python's built-in ordering, so the printout matches what the crew will actually do.

Task: Print the pallet weights in ascending order, arranging them with a selection sort you write yourself.

Input

A single line holding 1 to 1000 integers separated by single spaces. Weights may repeat and may be negative.

Output

One line holding every value in ascending order, separated by single spaces. Every value that came in must come out, repeats included.

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

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…