javascript - Sorting a HTML table with Array#sort - Stack Overflow

PHOTO EMBED

Sun Jul 31 2022 21:04:17 GMT+0000 (Coordinated Universal Time)

Saved by @riapacheco #javascript

let table = document.getElementById("table1");
let trs = table.rows;

Array.from(trs)
     .sort((a, b) => a.cells[0].textContent - b.cells[0].textContent)
     .forEach(tr => table.appendChild(tr));
content_copyCOPY

https://stackoverflow.com/questions/67853327/sorting-a-html-table-with-arraysort