I have a conflict between my lecture notes on quantum mechanics, where it is stated that the probability of measuring an eigenvalue $a_i$ on a mixed state with desnsity matrix $\rho$ is $$ \operatorname{Tr}(P_i \rho P_i)\ , $$ where $P_i$ is the projector for the subspace corresponding to $a_i$.
However, all resources out there states that the probability should be $\operatorname{Tr}(\rho P_i)$, and even the professor gave as a solved exam as an example where the later formula was applied instead of the first one.
Which calculation for the probability is correct? Is it possible that both traces are the same because of $P_i$ being a projection operator?