EN
Dirask - sort cross technology table
8
points
Quick solution:
(function sort(columnIndex) {
//const table = document.querySelector('table');
const table = document.querySelector('.cke_wysiwyg_frame')
.contentWindow.document.querySelector('table');
const rows = table.rows;
outer:
while (true) {
for (let index = 1; index < rows.length - 1; index++) {
const row1 = rows[index];
const row2 = rows[index + 1];
const text1 = row1.cells[columnIndex].innerText.toLowerCase();
const text2 = row2.cells[columnIndex].innerText.toLowerCase();
if (text1 > text2) {
row1.parentNode.insertBefore(row2, row1);
continue outer;
}
}
break;
}
})(0);
See also: