{"ScriptPreparationCode":null,"TestCases":[{"Name":"custom sort","Code":"const array1 = [1, 3, 9];\r\nconst array2 = [2, 9, 4];\r\n\r\nlet array = mergeSort(array1, array2);\r\n\r\nconsole.log(array);\r\n\r\nfunction mergeSort(array1, array2) {\r\n\t//comparing two popular merging techniques spread is slightly faster so that\u0027s being used\r\n //merge arrays\r\n let mergedArray = [...array1, ...array2];\r\n \r\n //sort arrays\r\n \t\r\n // loop through array\r\n\t\tfor (let i = 0; i \u003C mergedArray.length - 1; i\u002B\u002B) {\r\n \t//set first index\r\n let min = i;\r\n \r\n //loop through array again\r\n for (let j = i \u002B 1; j \u003C mergedArray.length; j\u002B\u002B) {\r\n \t\t//check if number in first array is smaller if reset index\r\n if (mergedArray[j] \u003C mergedArray[min]) {\r\n min = j;\r\n }\r\n }\r\n \r\n //if index of first for has been reset above it\u0027s diffirent which means we can add it to end of the array\r\n if (min != i) {\r\n let target = mergedArray[i];\r\n mergedArray[i] = mergedArray[min];\r\n mergedArray[min] = target;\r\n }\r\n }\r\n \r\n return mergedArray;\r\n \r\n //return mergedArray.sort((a,b) =\u003E a-b);\r\n}","IsDeferred":false},{"Name":"normal sort","Code":"const array1 = [1, 3, 9];\r\nconst array2 = [2, 9, 4];\r\n\r\nlet array = mergeSort(array1, array2);\r\n\r\nconsole.log(array);\r\n\r\nfunction mergeSort(array1, array2) {\r\n\t//comparing two popular merging techniques spread is slightly faster so that\u0027s being used\r\n //merge arrays\r\n let mergedArray = [...array1, ...array2];\r\n \r\n //sort arrays\r\n \t\r\n return mergedArray.sort((a,b) =\u003E a-b);\r\n}","IsDeferred":false}]}