I was going through Qiskit online text book and came across this part. The relevant (slightly modified) paragraph is -
Suppose we have two states $|\psi_0\rangle$ and $|\psi_2\rangle$. Their inner product would be $\langle\psi_0|\psi_1\rangle$. If we apply the same $U$ to both, the inner product of the resulting states would still be the same -
The Hermitian conjugate of first state, after applying $U$ would be $\langle\psi_0|U^\dagger$. So inner product would be $$(\langle\psi_0|U^\dagger)\ (|\psi_1\rangle U)= \langle\psi_0|UU^\dagger|\psi_1\rangle =\langle\psi_0|\psi_1\rangle $$ This property provides us with a useful way of thinking about these gates. It means that for any set of states $\{|\psi_j\rangle\}$, that provide an orthonormal basis for our system, the set of states$\{|\phi_j\rangle=U|\psi_j\rangle\}$ will also be an orthonormal basis. The unitary can then be thought of as a rotation between these bases, and can be written accordingly as $$U = \sum_j{\lvert\phi_j\rangle\langle\psi_j\rvert}$$
I didn't really get the last part. How is $U = \sum_j{\lvert\phi_j\rangle\langle\psi_j\rvert}$ is connected to preceding discussion? How does this follow from previous discussion?
My second question is how $U = \sum_j{\lvert\phi_j\rangle\langle\psi_j\rvert}$ is mapping operator as described in this post? How is this derived?