{"ScriptPreparationCode":"const max =100;\r\nconst type = 0;\r\n unsorted= [];\r\nconst sample = 1100000000;\r\nwhile (unsorted.length \u003C max) {\r\n\tconst count = unsorted.length;\r\n\tlet t = 0;\r\n\tif(type === 0) {\r\n\t\tt = Math.floor(Math.random() * (sample*2)) \u002B sample;\r\n\t} else if(type === 1) {\r\n\t\tt = sample \u002B (count*1000);\r\n\t} else if(type === 2) {\r\n\t\tt = sample - (count*1000);\r\n\t}\r\n\tif(unsorted.findIndex(it =\u003E it.timestamp === t) === -1) {\r\n\t\t unsorted.push({\r\n proceedingTime: 20,\r\n maxWaitingTime: \u0027asjdsjadsajdjsadadasd\u0027,\r\n maxWaitingTimeEnabled: true,\r\n alertWaitingDelay: 60,\r\n maintainPositionTime: \u00272387423784723847823487\u0027,\r\n maintainWaitingPosition: true,\r\n timestamp: t\r\n });\r\n }\r\n}\r\n\r\nfunction builtin_sort(unsorted) {\r\n return unsorted.sort((a, b) =\u003E {\r\n return a.timestamp - b.timestamp;\r\n });\r\n}\r\n\r\nfunction naive_quicksort(ary) {\r\n if (ary.length \u003C= 1) {\r\n return ary;\r\n }\r\n var less = [],\r\n greater = [],\r\n pivot = ary.pop();\r\n for (var i = 0; i \u003C ary.length; i\u002B\u002B) {\r\n if (ary[i].timestamp \u003C pivot.timestamp) {\r\n less.push(ary[i]);\r\n } else {\r\n greater.push(ary[i]);\r\n }\r\n }\r\n less = naive_quicksort(less);\r\n greater = naive_quicksort(greater);\r\n return less.concat(pivot, greater);\r\n}\r\n\r\nfunction insertion_sort(ary) {\r\n for (var i = 1, l = ary.length; i \u003C l; i\u002B\u002B) {\r\n var value = ary[i];\r\n for (var j = i - 1; j \u003E= 0; j--) {\r\n if (ary[j].timestamp \u003C= value.timestamp)\r\n break;\r\n ary[j \u002B 1] = ary[j];\r\n }\r\n ary[j \u002B 1] = value;\r\n }\r\n return ary;\r\n}\r\n\r\nfunction shell_sort(ary) {\r\n var inc = Math.round(ary.length / 2),\r\n i, j, t;\r\n while (inc \u003E 0) {\r\n for (i = inc; i \u003C ary.length; i\u002B\u002B) {\r\n t = ary[i];\r\n j = i;\r\n while (j \u003E= inc \u0026\u0026 ary[j - inc].timestamp \u003E t.timestamp) {\r\n ary[j] = ary[j - inc];\r\n j -= inc;\r\n }\r\n ary[j] = t;\r\n }\r\n inc = Math.round(inc / 2.2);\r\n }\r\n return ary;\r\n}\r\n\r\nfunction inplace_quicksort_partition(ary, start, end, pivotIndex) {\r\n var i = start, j = end;\r\n var pivot = ary[pivotIndex];\r\n while (true) {\r\n while (ary[i].timestamp \u003C pivot.timestamp) { i\u002B\u002B };\r\n j--;\r\n while (pivot.timestamp \u003C ary[j].timestamp) { j-- };\r\n if (!(i \u003C j)) {\r\n return i;\r\n }\r\n swap(ary, i, j);\r\n i\u002B\u002B;\r\n }\r\n}\r\n\r\nfunction inplace_quicksort(ary, start, end) {\r\n if (start \u003C end - 1) {\r\n var pivotIndex = Math.round((start \u002B end) / 2);\r\n pivotIndex = inplace_quicksort_partition(ary, start, end, pivotIndex);\r\n inplace_quicksort(ary, start, pivotIndex - 1);\r\n inplace_quicksort(ary, pivotIndex \u002B 1, end);\r\n }\r\n return ary;\r\n}\r\n\r\nfunction fast_quicksort(ary) {\r\n var stack = [];\r\n var entry = [0, ary.length, 2 * Math.floor(Math.log(ary.length) / Math.log(2))];\r\n stack.push(entry);\r\n while (stack.length \u003E 0) {\r\n entry = stack.pop();\r\n var start = entry[0];\r\n var end = entry[1];\r\n var depth = entry[2];\r\n if (depth == 0) {\r\n ary = shell_sort_bound(ary, start, end);\r\n continue;\r\n }\r\n depth--;\r\n var pivot = Math.round((start \u002B end) / 2);\r\n var pivotNewIndex = inplace_quicksort_partition(ary, start, end, pivot);\r\n if (end - pivotNewIndex \u003E 16) {\r\n entry = [pivotNewIndex, end, depth];\r\n stack.push(entry);\r\n }\r\n if (pivotNewIndex - start \u003E 16) {\r\n entry = [start, pivotNewIndex, depth];\r\n stack.push(entry);\r\n }\r\n }\r\n ary = insertion_sort(ary);\r\n return ary;\r\n}\r\n\r\nfunction shell_sort_bound(ary, start, end) {\r\n var inc = Math.round((start \u002B end) / 2),\r\n i, j, t;\r\n while (inc \u003E= start) {\r\n for (i = inc; i \u003C end; i\u002B\u002B) {\r\n t = ary[i];\r\n j = i;\r\n while (j \u003E= inc \u0026\u0026 ary[j - inc].timestamp \u003E t.timestamp) {\r\n ary[j] = ary[j - inc];\r\n j -= inc;\r\n }\r\n ary[j] = t;\r\n }\r\n inc = Math.round(inc / 2.2);\r\n }\r\n return ary;\r\n}\r\n\r\nfunction swap(ary, a, b) {\r\n var t = ary[a];\r\n ary[a] = ary[b];\r\n ary[b] = t;\r\n}","TestCases":[{"Name":"builtin_sort","Code":"const sorted = builtin_sort(unsorted.slice());","IsDeferred":false},{"Name":"insertion_sort","Code":"const sorted = insertion_sort(unsorted.slice());","IsDeferred":false},{"Name":"shell_sort","Code":"const sorted = shell_sort(unsorted.slice());","IsDeferred":false},{"Name":"inplace_quicksort","Code":"const un = unsorted.slice();\r\nconst sorted = inplace_quicksort(un, 0, un.length-1);","IsDeferred":false},{"Name":"fast_quicksort","Code":"const sorted = fast_quicksort(unsorted.slice());","IsDeferred":false}]}