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

130
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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