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

145
Views
How to chain a sort to this data filtration

What would be the proper way to add on a sort as a method chain here?

let data = [
    {'country': 'US', 'state': 'DE'},
    {'country': 'US', 'state': 'CA'},
    {'country': 'US', 'state': 'MI'},
    {'country': 'RU', 'state': null}
];
let us_data = data
    .filter(elem => elem['country'] === 'US')
    .filter(elem => ['CA', 'DE'].includes(elem['state']))
   // .sort((a,b) => a['state'] < b['state']) ???
console.log(us_data);

In other words, the correct way to add on the sort in the above (but not in-place?)

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!