Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

151
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda