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

190
Views
how to sort this two sub array [ { [ ] } ,{ [ ] } , { [ ] } ,] in javascript

how can i sort this tests array based on discount_price i have sorted only the lab_partners array,,,can anyone tell me how to sort the main array nd so that array should look something like : 200 ,250, 299 ,500 so my array is something like this - [ { [ ] } ,{ [ ] } , { [ ] } ,]

"tests": [
 {
   "id": 11,
  "habit_test_id": 3,
  "test_id": 1,
  "test": {
           "id": 1,
            "test_name": "Blood Test",
          },
   "lab_partners": [
  {
     "id": 1,
    "discounted_price": 250, 
  },
  {
     "id": 7,
     "discounted_price": 299,

    }
   ]
 },
 {

 "test": {
     "id": 4,
     "test_name": "MRI",

      },
 "lab_partners": [
     {
    "id": 6,

   "discounted_price": 500,

  },
  {
    "id": 6,

   "discounted_price": 200,

  }
 ]
 }
]
}

//this only sort the lab_partners array i want to sort on the basis of both test array

 const condition_based=   tests.map((itr, idx) =>
  itr.lab_partners.sort((firstItem, secondItem) => ( firstItem.discounted_price - 
  secondItem.display_price)));
  console.log(condition_based,'condition_based');
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I don't really know what you are trying to achieve, or what you expect from this array, but please look into this

https://www.w3schools.com/JS/js_object_constructors.asp

It seems to me like there are some similarities in all the object values, and you are missing out some maybe just because they are null values.

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!