I have two 2D arrays
array1 = np.array(
[[1, 2],
[2, 1],
[3, 3]])
array2 = np.array(
[[2, 3],
[3, 2],
[1, 1]])
I want to sort array2 in a way so that the values and order in the second column of array1 matches with first column of array2
desired output would be a numpy array that looks like this
sorted_array2 =
[[2, 3]
[1, 1]
[3, 2]]
then combine the two arrays to get a final array like this
[[1, 2, 3],
[2, 1, 1],
[3, 3, 2]]
Thank you for your time.
1