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

154
Views
Javascript - Sorting an array of objects based on another array

I have two arrays. They look like this but are longer in my code.

let arrayA = [{heading: "heading2", body: "text body2"}, {heading: "heading", body: "text body"}, {heading: "heading4", body: "text body4"}, {heading: "heading3", body: "text body3"}]
let arrayB = ["heading", "heading2", "heading 3", "heading 4"]

My html page needs to loop over arrayA and for each item return

<h1>item.heading</h1>
<p>item.body</p>

How would i go about sorting arrayA to get the same order as arrayB ?

about 4 years ago · Juan Pablo Isaza
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!