Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

118
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda