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

93
Views
JavaScript sorting array of objects by description field in the object

I'm not very skilled with JavaScript and I have an issue where I need to sort array based on description. I looked several topics and I have tried to sort it but so far no luck..

I have an array of objects that looks like this:

{
  category: null,
  code: "GGG",
  id: 3,
  description: "Gama"
},    
{
  category: null,
  code: "AAA",
  id: 1,
  description: "Alfa"
},
{
  category: null,
  code: "BBB",
  id: 2,
  description: "Beta"
}

And this array is returned by a function that says:

return result.data

So want to sort that result set based on description on ascending order, which means my list would look like this after the return: "Alfa", "Beta", "Gama".

I was trying to use sort function:

return result.data.sort();

But that didn't help me.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can do:

result.data.sort((a, b) => a.description.localeCompare(b.description)));
about 4 years ago · Juan Pablo Isaza Report
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!