โ† Amazon questions

Sort array based on relative order of another array

Filed under Amazon

Given two arrays A1 and A2, sort A1 such that the relative order of elements matches their order in A2. Elements not present in A2 should be placed at the end in ascending sorted order.

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Amazon questions

Collected from public candidate posts and coding forums. Updated Nov 2026.