Python solution
\n# Code\n\nfrom typing import List\n\nclass Solution:\n    def sortJumbled(self, mapping: List[int], nums: List[int]) -> List[int]:\n        def get_mapped_val
\n# Code\n```\nfrom typing import List\n\nclass Solution:\n    def sortJumbled(self, mapping: List[int], nums: List[int]) -> List[int]:\n        def get_mapped_value(num: int) -> int:\n            mapped_num_str = \'\'.join(str(mapping[int(digit)]) for digit in str(num))\n            return int(mapped_num_str)\n        mapped_values = [(num, get_mapped_value(num)) for num in nums]\n        mapped_values.sort(key=lambda x: x[1])\n        return [num for num, _ in mapped_values]    \n```\n\n### Example with Step-by-Step Mapping:\n\n**Input:**\n- `mapping = [8, 9, 4, 0, 2, 1, 3, 5, 7, 6]`\n- `nums = [991, 338, 38]`\n\n**Step 1: Mapping each number**\n\n1. **For `991`**:\n   - The number `991` has digits `9`, `9`, and `1`.\n   - According to `mapping[9]`, digit `9` maps to `6`.\n   - According to `mapping[1]`, digit `1` maps to `9`.\n   - So, `991` is mapped to `669`.\n\n2. **For `338`**:\n   - The number `338` has digits `3`, `3`, and `8`.\n   - According to `mapping[3]`, digit `3` maps to `0`.\n   - According to `mapping[8]`, digit `8` maps to `7`.\n   - So, `338` is mapped to `007`, which is `7` after removing leading zeros.\n\n3. **For `38`**:\n   - The number `38` has digits `3` and `8`.\n   - According to `mapping[3]`, digit `3` maps to `0`.\n   - According to `mapping[8]`, digit `8` maps to `7`.\n   - So, `38` is mapped to `07`, which is `7` after removing leading zeros.\n\n**Step 2: Pair original numbers with their mapped values**\n- `[(991, 669), (338, 7), (38, 7)]`\n\n**Step 3: Sort the pairs based on mapped values**\n- Sorted pairs: `[(338, 7), (38, 7), (991, 669)]`\n\n**Step 4: Extract original numbers from the sorted pairs**\n- Result: `[338, 38, 991]`\n\n### Explanation:\n1. **Mapping Details**:\n   - For `991`: Each `9` becomes `6` and `1` becomes `9`, resulting in `669`.\n   - For `338`: Each `3` becomes `0` and `8` becomes `7`, resulting in `007`, which simplifies to `7`.\n   - For `38`: `3` becomes `0` and `8` becomes `7`, resulting in `07`, which simplifies to `7`.\n\n2. **Original and Mapped Pairs**:\n   - `[(991, 669), (338, 7), (38, 7)]`\n\n3. **Sorting Based on Mapped Values**:\n   - We sort the pairs by the mapped values: `[(338, 7), (38, 7), (991, 669)]`.\n\n4. **Result**:\n   - Extracting the original numbers from the sorted pairs gives us `[338, 38, 991]`.\n\nThis is how the mapping and sorting process works to sort the `nums` array based on their mapped values.
['Python3']