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

202
Views
Sorting numbers in multiple columns and moving empty or null to the bottom

I want to sort 2 columns and gettin the empty rows to the bottom, but i am a bit stuck on it. I've found multiple examples of both, and I can get them working separately from each other, but not simultaneous. Can somebody please provide me with an example?

    results.sort(   (a, b) => {
    var key = racetimefieldnames[setlastpartiallyfullcolumn];
    var keybefore = racetimefieldnames[setlastpartiallyfullcolumn-1];
    var aa = a[keybefore];
    var bb = b[keybefore];
    a = a[key];
    b = b[key];
    
    
    
    if(a === "" || a === null) return 1;
    if(b === "" || b === null) return -1;

    if (a > b) return 1;
    if (a < b) return -1;
    
    
    if (aa > bb) return 1;
    if (aa < bb) return -1;
    
    return 0;
    }); 
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!