Say I have two arrays. One is :
A = [a, b, c, d]
and another is,
B = [w, x, y, z]
Each element in A corresponds to the respective element in B
(i.e. a -> w, b -> x, c -> y, d -> z)
Now I want to sort the array A in increasing order of an attribute (say value) of the elements of B
(eg. w.value = 3, x.value = 2, y.value = 1, z.value = 4)
Hence, my desired output is:
[c, b, a, d]
How do I do this using Javascript? Any help will be appreciated. I am stuck at this for a long time.