Suppose I have two arrays:
arr1 = [64, 23, 35, 11, 55];
arr2 = [34, 10, 54, 12, 4];
If I rearrange (or sort) arr1 then the elements of arr2 should also be rearranged as per the position (or index) of arr1.
For example: if I sort arr1
arr1 = [11, 23, 35, 55, 64];
then the elements in arr2 should be
arr2 : [12, 10, 54, 4, 34 ] (arranged according to index of arr1).
Is it possible? I found that it can be done in same array but I am trying with two different arrays. Thank you for helping.
arr1. You'll also need to think about what to do with duplicates. Do your research, search for related topics on SO, and give it a go. If you get stuck and can't get unstuck after doing more research and searching, post a minimal reproducible example of your attempt and say specifically where you're stuck. People will be glad to help. Good luck!