Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

129
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!