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

116
Views
How to sort an array of objects based on two properties of the object

I have an array of objects like this for example.

names = [{firstName: "Rachel", lastName: "Green"}, {firstName: "Monica", lastName: "Geller"},
        {firstName: "Ross", lastName: "Geller"}, {firstName: "Phoebe", lastName: "Buffay"}]

I want to sort the array firstName and if the firstName is same then sort the bunch of objects with same firstName by the lastName. Like it is done in MYSQL while we give ORDER BY keyword in query, but I want to do it in javascript in an optimal manner, any suggestions?

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!