Question: A strange sorting algorithm... Python 3 2. A Strange Sorting Problem 10 11 12 13 14 15 Due to a bug in a trading program,

A strange sorting algorithm... Python 3A strange sorting algorithm... Python 3 2. A Strange Sorting Problem 1011 12 13 14 15 Due to a bug in a tradingprogram, the digits of the decimal system got reshuffled. For instance, eacho changed to 2, each 1 got changed to 3 and each

2. A Strange Sorting Problem 10 11 12 13 14 15 Due to a bug in a trading program, the digits of the decimal system got reshuffled. For instance, each o changed to 2, each 1 got changed to 3 and each 2 got changed to 0. If the correct number is "021", the system shows "203". The users of the trading software care about the relative values of their positions. Before rolling out the fix for the underlying issue, the company decided to first issue a modified sorting patch that will show the relative order based on the correct values, sorted ascending. 16 17 18 * 19 20 21 22 23 24 25 26 > Given the numbers that the program needs to sort and the mapping, i.e. the shuffled version of the decimal digits, return a list of the jumbled numbers sorted by their correct decimal values, ascending. If multiple mapped values are equal, the values returned should be in the original order they were presented. For example, mapping = (3,5,4,6,2,7,9,8,0,11 of fixed length of m = 10 and another array of numbers strings, nums = [1990','332', '32'] of length n = 3. Map '990' as follows: 9 The first digit is '9'. In the mapping array, 9 is at position 6 so the first digit of the mapped value is '6. The second digit is '9'. Again, the value is at position 6, so the mapped value is now '66'. .. Test Res Type here to search Bte AL Map '990' as follows: The first digit is '9'. In the mapping array, 9 is at a position 6 so the first digit of the mapped value is '6'. The second digit is '9'. Again, the value is at position 6, so the mapped value is now '66. The third digit is '0', found at position 8 of the mapping array. The mapped value is '668' or 668 as an integer. Map '332' as: The first and second digits are both '3' which is found at index 0 in mapping. The mapped value is '00'. The third digit is '2' found at index 4 of mapping, so the mapped value is '004' or 4 as an integer. The value '32' maps to '04', or integer 4, which equals the previous value. Ordering by integer values yields [4, 4, 668], and retaining order for '332' and '32' results in a return array of associated original values: ['332', '32; 1990'). Function Description Complete the function strangeSort in the editor below. The function must return an array of strings. strangeSort has the following parameter(s): mapping[mapping[0]....mapping[m-1]]: an array of integers, denoting the first 10 digits in the number system. O Type here to search Q BACA array of associated original values: ['332' '32', '990'). Function Description Complete the function strange Sort in the editor below. The function must return an array of strings. strangeSort has the following parameter(s): mapping[mapping[0]....mapping[m-1]]: an array of integers, denoting the first 10 digits in the number system. nums[nums[0]....nums[n-1]]: an array of strings, denoting the array that needs to be sorted. Constraints LE . m = 10 1sns 104 1 s length of each nums[i] #!/bin/python3 ... # Complete the 'strangeSort' function below. & co no UI + # The function is expected to return a STRING # The function accepts following parameters: # 1. INTEGER_ARRAY mapping # 2. STRING_ARRAY nums # 20 21 def strangeSort(mapping, nums): # Write your code here for i in range (len(mapping)): 22 23 24 25 26 > if __name__ == '__main__': --- Test Results Custom Input

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!