I’m using javascript and trying to sync two arrays so that both arrays have the same index location.
var array1 = ["word1","word2","word3","word4","word5"];
var array2 = [1,2,3,4,5];
array2.sort(function(){ return Math.random() -.5});
This scrambles array2 into something like [2,3,1,5,4]
Now I need array1 to get the same order: ["word2", "word3", "word1", "word 5", "word4"]
How can I do this?
Something like this should be a pretty simple way to do it: