I'll prove the following fact which you may find useful in general: Let $A$ and $B$ be two matrices. If either of the products $AB$ or $BA$ is well-defined and square, then they both are, and $\mathrm{Tr}(AB)=\mathrm{Tr}(BA)$.
Proof: That $AB$ is well-defined and square means that $B$ is the same shape as the transpose of $A$, so $BA$ is also well-defined and square. So let $A$ have dimensions $m\times n$ and $B$ have dimensions $n\times m$. Then the trace of $AB$ is $\sum_{i=1}^m (AB)_{ii} = \sum_{i=1}^m\sum_{j=1}^n a_{ij} b_{ji}$, and interchanging the order of summations we get $\sum_{j=1}^n \sum_{i=1}^m b_{ji}a_{ij} = \sum_{j=1}^n(BA)_{jj}$, which is the trace of $BA$.
In your case, you just need to apply this result to the matrices $\langle\psi|$ and $A|\psi\rangle$: you obtain $\mathrm{Tr}(A|\psi\rangle\langle\psi|) = \mathrm{Tr}(\langle\psi|A|\psi\rangle) = \langle\psi|A|\psi\rangle$, since the latter is just a number.