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

287
Vistas
How to sort an array based on another array? (Javascript)

I have an array containing rows (tr elements) of a table:

var tbody = document.querySelector("#tasktable tbody");
var rows = [].slice.call(tbody.querySelectorAll("tr"));

Each of these rows has an input date element, in which I've stored each date value in an array and converted the date into a number (originally a string). Ex: "10-24-2021" --> 20211024.

I can easily sort the array of numeric date values in ascending order by:

dateArray.sort(function(a,b){
    return a-b;
});

However, I really just want to sort the rows in the table. How do I sort the row array based on the way the date array was sorted, since each date corresponds to the row by their index?

Thank you!

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