✅🔥EASIER TOT UNDERSTAND || CODE WITH COMMENTS || BEATS 100% JS SOLTUON 🥇✅
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(nlogn)$$\n- Space complexity:\n$$O(n)$$\n\n\n![sORT tHE JUMBLED ARRAY.jpg](https://assets.leetcode.com/users/images/9ee88263-0301-4cad-909a-8b95f2f86d49_1721790888.2609167.jpeg)\n\n# Code\n```\n/**\n * @param {number[]} mapping\n * @param {number[]} nums\n * @return {number[]}\n */\nvar sortJumbled = function(mapping, nums) {\n    // Create an array to hold the original numbers and their mapped values\n    let mapped = [];\n\n    // Loop through each number in nums array\n    for(let n of nums) {\n        // Convert the number to a string for easier manipulation of each digit\n        let str = String(n);\n        // Initialize an empty string to store the mapped value of the current number\n        let maps = "";\n        // Loop through each character (digit) in the string representation of the number\n        for(let c of str) {\n            // Append the mapped value of the current digit to the maps string\n            maps += mapping[c];\n        }\n        // Push the original number and its mapped value as a pair into the mapped array\n        mapped.push([n, Number(maps)]);\n    }\n    \n    // Sort the mapped array based on the mapped values\n    mapped.sort((a, b) => {\n        if(a[1] === b[1]) {\n            // If two numbers have the same mapped value, maintain their original relative order\n            return 0;\n        }\n        else {\n            // Otherwise, sort them based on their mapped values in ascending order\n            return a[1] - b[1];\n        }\n    });\n   \n    // Create an array to hold the result\n    let result = [];\n    \n    // Extract the original numbers from the sorted mapped array and push them to the result array\n    for(let m of mapped) {\n        result.push(m[0]);\n    }\n\n    // Return the result array\n    return result;\n};\n```
['JavaScript']