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

224
Vistas
Implementing tree sorting without creating extra function

I have a function which sorts my data tree according to it's items order

  const itemSorter = (items) =>
  items
    .map((item) => (item?.children ? { ...item, children: itemSorter(item.children) } : item))
    .sort((i1, i2) => i1.order - i2.order);

 sortItems(dataTree);

So my question is:
Is it possible to implement the same logic without creating function itemSorter, just start with

return dataTree.map(.... and so on) 

or that's impossible when we use recursion and we always need the name?

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