Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

157
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda