code is a permutation of the digits 0 to 9: digit d is replaced with code[d]. To get the **code** of a number, replace every digit of its decimal form using the cipher and read the result as a number (leading zeros are dropped).
You are given an array values. Sort it by the codes of its elements in ascending order and return the result. The answer holds the original numbers, not their codes. Numbers with equal codes keep their relative order from values.code=[3, 1, 4, 0, 5, 9, 2, 6, 8, 7], values=[40, 13, 7] → [7, 13, 40]
40 turns into 53 (4 → 5, 0 → 3), 13 into 10 (1 → 1, 3 → 0), and 7 into 6. By coded value: 7, 13, 40.
code=[5, 0, 1, 2, 3, 4, 6, 7, 8, 9], values=[11, 1, 50] → [11, 1, 50]
11 turns into 00, which is 0, and 1 also turns into 0, so they keep their original order. 50 turns into 45 and goes last.
code=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], values=[21, 3] → [3, 21]
code is a permutation of the digits 0–9code=[3, 1, 4, 0, 5, 9, 2, 6, 8, 7], values=[40, 13, 7]
[7, 13, 40]
Run checks the first 3 tests in your browser. Submit checks all 100 tests on the server, hidden ones included.