In the Nielsen and Chuang book page 76, equation 2.60 says that we can rewrite the trace $$Tr(A \left|\psi\right>\left<\psi\right|)$$ as follow :
$$Tr(A \left|\psi\right>\left<\psi\right|) = \sum_{i}^{}\langle i| A | \psi \rangle \langle \psi | i \rangle = \langle \psi | A | \psi \rangle$$
I understand the idea behind, but I don't manage to do the calculus with the gram-schmidt procedure can lead to such a result.
On addition, I don't understant how $$\sum_{i}^{}\langle i| A | \psi \rangle \langle \psi | i \rangle = \langle \psi | A | \psi \rangle$$