I want to make a sorting algorithm that sorts one array of doubles from least to greatest. I want to make it so that another array is rearranged exactly the same way as the first array.
Example:
Array1 = {3, 4, 2, 1}
Array2 = {5, 6, 7, 8}
Sort
Array1 = {1, 2, 3, 4}
Array2 = {8, 7, 5, 6}
How would I go about doing this? What’s the fastest sorting algorithm for doing something like this? The arrays will be long, as in length > 1000. They will both be of the same length.