I have a matrix and want to sort its eigenvalues in a ascending order. Also I want to have the eigenstates corresponding to the eigenvalues at the same time. So I used:
where M is my matrix. However, when I test this code by using
the eigenvalues are not in right order. Can I know why is this and how to fix it?
Moreover, what should I do if I want to sort the eigenvalues in a descending order?