Imagine I have two sets of items. The first set is:
A = [apple, banana, cherry, date]
and the second set is,
B = [watermelon, xigua, yuzu, zucchini]
Each item in A corresponds to the respective item in B
(i.e. apple -> watermelon, banana -> xigua, cherry -> yuzu, date -> zucchini)
Now I aim to arrange the items in A in ascending order based on a certain property (let's say size) of the items in B
(e.g. watermelon.size = 3, xigua.size = 2, yuzu.size = 1, zucchini.size = 4)
So, I want the output to be:
[cherry, banana, apple, date]
How can I achieve this using JavaScript? Any assistance would be greatly appreciated as I've been struggling with this for quite some time.