I have the following scenario
$elementsInPairs = ["xyz","xxx","yyy","zzz"];
$valuesInPair =[4,2,3,1];
and i need to sort the second array which would give me
[1,2,3,4]
which i can do by
sort($valuesInPair)
but i need the same to happen in first array as well, based on the sorting of the second array
["zzz","xxx","yyy","xyz"];
EDIT As i had to fix it urgently, i guess i wasn't able to share more information, and the question seemed vague
basically the idea is that i have two sets of arrays, same number of elements in all cases, and they are linked to each other, The second array is a set of order IDs. and first array is set of names, so in the above example, i have
4 relates to xyz
2 relates to xxx
3 relates to yyy
1 relates to zzz
So i need to sort based on IDs, and have the same order reflect in the first array as well,
so the final result would be,
["zzz","xxx","yyy","xyz"];
which is sorted based on
[1, 2, 3, 4];
Hopefully this clears things above
["zzz","yyy","xxx","xyz"];so like reversing the array? Because I dont see a pattern in your "order" for the array with letters. xxx and yyy comes before zzz if you order by alphabetic, so what is the idea behind the ordering?