The TransCompilator

Solved LeetCode program · 840 of 1,000

#1122 · Relative Sort Array

Easy Array chunk-17.md

Original English source

The numbers is a list of 2, 3, 1, 3, 2, 4, 6, 7, 9, 2, and 19. The wanted is a list of 2, 1, 4, 3, 9, and 6. The counts is a list of 1001 zeros.
For each value in numbers.
Increase item value of counts by 1.

The answers is an empty list of whole numbers.
For every spot from 0 to the last position of wanted.
The value is item spot of wanted. The many is item value of counts. Set item value of counts to 0.
For every repeat from 1 to many.
Place value into answers.

For every value from 0 to 1000.
The many is item value of counts.
If many is more than 0.
For every repeat from 1 to many.
Place value into answers.

The parts is an empty list of text.
For each value in answers.
The piece is format whole number value as text. Place piece into parts.

The line is join parts with ",". Show line.

Open in Playground Browse all 1,000 problems

Expected stdout

2,2,2,1,4,3,3,9,6,7,19