C++ || With explanation || Using Priority Queue Custom Comparator
\nclass Solution {\npublic:\n    struct cmp\n    {\n        bool operator()(pair<int,pair<int,int>> a,pair<int,pair<int,int>> b)\n        {\n            if(a.fi
```\nclass Solution {\npublic:\n    struct cmp\n    {\n        bool operator()(pair<int,pair<int,int>> a,pair<int,pair<int,int>> b)\n        {\n            if(a.first!=b.first) return a.first>b.first; //checks if mapped value is not same and returns smaller of both\n            return a.second.second>b.second.second; //if mapped value is same then checks with index to maintian relative order\n        }\n    };\n    \n    vector<int> sortJumbled(vector<int>& mapping, vector<int>& nums) {\n        //priority queue with with mapped value, original number, index\n        priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,cmp> pq;\n        \n        for(int i=0;i<nums.size();++i)\n        {\n            string n = to_string(nums[i]); //converting nums[i] to string to access each index of number\n            string mapped_val=""; //stores converted mapped value\n            \n            for(int j=0; j<n.size(); ++j)\n                mapped_val+=to_string(mapping[n[j]-\'0\']); //converting to mapped value index by index\n            \n            pq.push({stoi(mapped_val),{nums[i],i}}); //pushing mapped value along with original number and index\n        }\n        \n        vector<int> ans; //stores answer\n        while(!pq.empty())\n        {\n            ans.push_back(pq.top().second.first); //top has the mapped value sorted in non-decreasing order\n            pq.pop();\n        }\n        return ans;\n    }\n};\n```
['C', 'Heap (Priority Queue)']