I'm not sure if this is what you're asking, but the order of the elements in the diagonal matrix has to be in the corresponding order to the eigenvectors used. That way, your eigenvalues correspond to the correct eigenvector. I'm not familiar with Quantum Physics at all, so ignore this if it's not what you're asking.