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

149
Views
How can i sort data by three properties?

I have the following array

let arr = [
    {
        "creationDateTime": 1632180639045,
        "pricePerUnitPerHour": 12,
        "divisible": false,
    },

    {
        "creationDateTime": 2504091567119,
        "pricePerUnitPerHour": 12,
        "divisible": true,
    },

    {
        "creationDateTime": 1504095567183,
        "pricePerUnitPerHour": 5,
        "divisible": true,
    }, 
]

I need to make the ascending sorting by these three properties pricePerUnitPerHour/divisible/and creationDateTime

So if for example two objects are having equal values in pricePerUnitPerHour then the sorting shoould be by divisible property. There divisible:true should be before the object where we have divisible:false.

And on the end if they have two equal prices, divisible property is true for example the sorting should be done based on the timestamp - creationDateTime

I got stuck at

 tableSort() {
    this.searchFilteredData.sort(
      function (a, b) {
        return b.pricePerUnitPerHour - a.pricePerUnitPerHour;
      });
  }
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!