Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

233
Views
Why does this function to sort the rows of a table work in Firefox but not in chrome?

I have some code to sort the body of a table that is all numbers. It works on firefox, but on chrome it does not update the table. On chrome, the sort function does not seem to change the order of the tr elements in the array.

function sortTable(col, dir = 1) {

    var tb = document.getElementById("vote_table").tBodies[0];
    tr = Array.prototype.slice.call(tb.rows, 0);

    tr = tr.sort(
            function (a, b) 
            { 
                return dir*parseInt(a.cells[col].textContent) < dir*parseInt(b.cells[col].textContent);               
            }
       );
    
    alert(tr[0].cells[col].textContent);

    for(var i = 0; i < tr.length; ++i) 
    { 
        tb.appendChild(tr[i]);  
    } // append each row in order
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!