Custom comparator - Java -Clean code
\nclass Solution {\n    public int[] sortJumbled(int[] mapping, int[] nums) {\n        \n        List<Integer> arr = new ArrayList<>();\n\t\t\n\t\t//Copying num
```\nclass Solution {\n    public int[] sortJumbled(int[] mapping, int[] nums) {\n        \n        List<Integer> arr = new ArrayList<>();\n\t\t\n\t\t//Copying numbers to arraylist - O(N)\n        for (int i = 0; i < nums.length; i++) {\n            arr.add(nums[i]);\n        }\n        \n\t\t//sorting arraylist as per mapping using custom comparator - O(N log  N)\n        Collections.sort(arr, new Comparator<Integer>() {\n           public int compare(Integer a, Integer b) {\n               \n\t\t\t   //evalute equivalent value after mapping\n               int val1 = evaluate(a, mapping);\n               int val2 = evaluate(b, mapping);\n               \n               return Integer.compare(val1, val2);\n           } \n        });\n\t\t\n\t\t//pack up - O(N)\n        for (int i = 0; i < nums.length; i++) {\n            nums[i] = (int) arr.get(i);\n        }\n\t\t\n\t\t//return\n        return nums;\n    }\n    \n\t//evaluate number\'s value after mapping\n    int evaluate(Integer num, int mapping[]) {\n        String str = Integer.toString(num);\n        StringBuilder val = new StringBuilder();\n        \n        for (int i =0 ; i < str.length(); i++) {\n            val.append((mapping[str.charAt(i) - \'0\']));\n        }\n        \n        return Integer.parseInt(val.toString());\n    }\n}\n```\n\n\nNote  : I tried using Arrays.sort with array of type Integer- Gives TLE \uD83E\uDD72
['Sorting', 'Java']