The bug is due to the "なし" being compared to the the integer from the other elements.
If you can fix it, I will give you 1000 keys as a reward.
Should be a quick fix.


function partition(arr, low, high, colIndex, direction) {
const pivot = parseFloat(arr[high].getElementsByTagName("TD")[colIndex].textContent);
let i = (low - 1);

for (let j = low; j <= high - 1; j++) {
const x = parseFloat(arr[j].getElementsByTagName("TD")[colIndex].textContent);
if ((direction === "asc" && x < pivot) || (direction === "desc" && x > pivot)) {
i++;
[arr[i], arr[j]] = [arr[j], arr[i]];
}
}
[arr[i + 1], arr[high]] = [arr[high], arr[i + 1]];
return (i + 1);
}