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

188
Views
JavaScript case insensitive sorting for HTML table

How I just want to implement Case - Insensitive Sort in this Javascript code for my Table. How can this be possible?

Please see below:

cPrev = -1; 
            
function sortBy(c) {
    rows = document.getElementById("data_table").rows.length; 
    columns = document.getElementById("data_table").rows[0].cells.length; 
    arrTable = [...Array(rows)].map(e => Array(columns)); 
    for (ro=0; ro<rows; ro++) {
        for (co=0; co<columns; co++) {
            arrTable[ro][co] = document.getElementById("data_table").rows[ro].cells[co].innerHTML;
        }
    }
    
}

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

To make it case insensitive just use .toLowerCase() or .toUpperCase()

document.getElementById("data_table").rows[ro].cells[co].innerHTML.toUpperCase()
about 4 years ago · Juan Pablo Isaza Report

0

This function works to sort strings alphabetically and places uppercase before lowercase.

function (a, b) {
   var x = String(a).toLowerCase(); 
   var y = String(b).toLowerCase(); 
     
   if (x > y) 
     return -1;
   if (x < y) 
     return 1; 
}
about 4 years ago · Juan Pablo Isaza Report
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!