{"ScriptPreparationCode":null,"TestCases":[{"Name":"for","Code":"let testArray = [1,3,1,2,31,23,5,6,8]\r\n\r\nfunction quickSort(arr){\r\n if(arr.length \u003C= 1) return arr\r\n const pivot = arr[arr.length - 1]\r\n let left = []\r\n let right = []\r\n for(let i = 0; i \u003C arr.length-1; i\u002B\u002B){\r\n if (arr[i] \u003C pivot) {\r\n left.push(arr[i])\r\n } else {\r\n right.push(arr[i])\r\n }\r\n }\r\n return [].concat(quickSort(left),pivot,quickSort(right))\r\n}\r\n\r\nquickSort(testArray)","IsDeferred":false},{"Name":"while","Code":"let testArray = [1,3,1,2,31,23,5,6,8]\r\n\r\nfunction quickSort(arr){\r\n if(arr.length \u003C= 1) return arr\r\n const pivot = arr.pop()\r\n let left = []\r\n let right = []\r\n while(arr[0]){\r\n if (arr[0] \u003C pivot) {\r\n left.push(arr.shift())\r\n } else {\r\n right.push(arr.shift())\r\n }\r\n }\r\n return [].concat(quickSort(left),pivot,quickSort(right))\r\n}\r\n\r\nquickSort(testArray)","IsDeferred":false}]}