0

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?

aca
  • 1,071
  • 5
  • 15
Sejal Naik
  • 21
  • 4

0 Answers0