No matter how the other elements are positioned, is important only the values along the diagonal.
For example I have matrix:
matrix = [[1, 3, 2],
[2, 5, -9],
[3, 4, 6]]
What I want to achieve is something the same as:
[[-9, 3, 2],
[6, 1, 5],
[3, 4, 2]]
I have tried:
>>> np_matrix = np.array(matrix)
>>> np_matrix.diagonal()
array([1, 5, 6])
>>> np.sort(np_matrix)
array([[ 1, 2, 3],
[-9, 2, 5],
[ 3, 4, 6]])
I think that I can get something from these methods, but I can not figure out how to make them work together. I appreciate all the help I can get.