I have a array in Python given by
matrix = [[10, -9, 8], [1, 15, 5]]
I want to sort the elements of the matrix[0] list so that matrix[1] is organized according to the ascending order of matrix[0]. The expected result would be:
matrix = [[-9, 8, 10], [15, 5, 1]]
My matrix represents values of X and Y. I want to sort X in ascending order so that Y is sorted according to the positions of X, in order to not lose the pairs formed by (X[i], Y[i]).
How can i do that?