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

132
Vistas
How to reorder using data from another object

Want to achieve

Vue 2.6.10

Thankyou for watching. I am creating an application in Vue.js.
Please tell me about sorting array data.

An object called shops_masters contains this data.
enter image description here

On the other hand,The data item.shops contains only the name of the shop data associated with the item, as shown below)

[c_shop,b_shop]

I want to sort the data in this item.shops in ascending order of the order_number of shops_masters, but I can't think of a way to do it.

I hope you can tell me about this one.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

First thing you wanna do is to create a map from entries like so:

const shopsMap = new Map(
  shops_masters.map(({ name, order_number }) => [name, order_number])
);

Then use it inside the sort method this way:

const sortedItemShops = item.shops.sort(
  (prev, next) => shopsMap.get(prev) - shopsMap.get(next)
);
about 4 years ago · Juan Pablo Isaza Denunciar
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