I have two arrays of the same size and I sort the second one. How can I array the first one to match?
Basic example (imagine replacing Ints with Strings):
var array1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
var array2 = [5, 2, 3, 4, 5, 6, 8, 5, 4, 5, 1]
array2.sort = ({ $0 > $1})
Result:
array2 is now [8, 6, 5, 5, 5, 5, 4, 4, 3, 2, 1]
How to sort array1's index value to match array2?
array1 should now be [6, 5, 0, 4, 7, 9, 3, 8, 2, 1, 0]