Introduction
Some of you may have heard of Hilbert's Grand Hotel. The manager there has lost his list of where the guests are staying but he still has the order in which they checked in. Each guest can not stay in a room with a room number less than their value and if a guest is added to a lower room, all guests in higher rooms with no empty space between them and the new guest are shifted up one room. Can you help him find where each of the guests are staying?
Requirements
Write a program which receives an ordered list of natural numbers as input and places them at their index. If there is already a value in that index, it is shifted up to the next entry in the list. This process repeats until the first empty (0 or undefined) space is found. Any undefined spaces between the current highest index and any new input will be filled by adding 0s. As this is Hilbert's Grand Hotel, rooms higher than the current highest occupied index do not exist.
Input and Output
Input will be an ordered list of natural numbers (allowed to be read through any accepted form of input)
Each number in the input is considered one guest arriving at the hotel and is in order of arrival
Output will be the final arrangement of guests (numbers)
Examples
Input: 1 3 1
Output: 1 1 3
Step by step:
1
Create room at index 1 and place 1 in it
1 0 3
Create rooms up to index 3 and place 3 in room 3
1 1 3
Shift the contents of room 1 up one room and place 1 in room 1Input: 1 4 3 1 2 1
Output: 1 1 2 1 3 4
Step by step:
1
Create room at index 1 and place 1 in it
1 0 0 4
Create rooms up to index 4 and place 4 in room 4
1 0 3 4
Place 3 in room 3
1 1 3 4
Shift contents of room 1 up one room and place 1 in room 1
1 2 1 3 4
Shift contents of rooms 2 to 4 up one room and place 2 in room 2
1 1 2 1 3 4
Shift contents of rooms 1 to 5 up one room and place 1 in room 1Input: 10
Output: 0 0 0 0 0 0 0 0 0 0 10
Step by step:
0 0 0 0 0 0 0 0 0 10
Create rooms up to room 10 and place 10 in room 10Notes:
Working with 0 indexed is fine and you may insert a 0 at the front of the output in that case
Standard loopholes are forbidden, shortest code in bytes wins