F
Size: a a a
F
{
TT
ВИ
F
${}`
, пальцы сломать можноT
О
{
const shuffleArray = arr => {
const len = arr.length
for (let i = 0; i < len - 1; i += 1) {
let r = Math.floor(Math.random() * (len - i))
r && ([arr[i], arr[i + r]] = [arr[i + r], arr[i]])
}
return arr
}
const chaoticArray = shuffleArray(Array(20).fill(0).map((_, i) => i + 1))
const mergeSort = array => {
const pivot = (start, end) => Math.floor((start + end) / 2);
const len = array.length
let tempA = [...array]
let tempB = tempA.splice(pivot(0, len), len - 1)
tempA = tempA.sort((a, b) => a - b)
tempB = tempB.sort((a, b) => a - b)
let i = 0
let j = 0
let k = 0
const result = []
while (k < len) {
if (tempA[i] < tempB[j]) {
result.push(tempA[i])
i++
} else {
result.push(tempB[j])
j++
}
k++
}
return result;
}
{
T
О
T
P
{
P
О