Closed payne911 closed 4 years ago
The very first row to be appended to the table is not taken into account by the current sorting algorithm:
The algo that is found in 2 different places (the Chrome Extension, and the Website):
function getTdValue(rows, index, col) { return rows.item(index).getElementsByTagName('td').item(col).getAttribute("value"); } /** 'sortColumn' index starts at 0. https://stackoverflow.com/a/37814596/9768291 */ function sortTable(table_id, sortColumn){ let tableData = document.getElementById(table_id).getElementsByTagName('tbody').item(0); let rows = tableData.getElementsByTagName('tr'); for(let i = 0; i < rows.length - 1; i++) { for(let j = 0; j < rows.length - (i + 1); j++) { if(getTdValue(rows, j, sortColumn) < getTdValue(rows, j+1, sortColumn)) { tableData.insertBefore(rows.item(j+1), rows.item(j)); } } } }
For posterity: the bug was that the sorting was happening based on the very first digit of a column's numbers.
The very first row to be appended to the table is not taken into account by the current sorting algorithm:
The algo that is found in 2 different places (the Chrome Extension, and the Website):