I'm following a book where the author tries to prove that $$\langle p \rangle = \langle \psi \vert \hat{p} \vert \psi \rangle,\tag{0}$$ so he just computes the integral
$$ \langle \psi \vert \hat{p} \vert \psi \rangle ~=~ \int_{\mathbb{R}} \psi^*(x) \left( -i\hbar \dfrac{\mathrm{d}}{\mathrm{d}x} \right) \psi(x) \, \mathrm{d}x \tag{1} $$
and starts by saying that
$$ -i\hbar\dfrac{\mathrm{d}\psi(x)}{\mathrm{d}x} ~=~ -i\hbar\dfrac{\mathrm{d}}{\mathrm{d}x} \int_{\mathbb{R}} \tilde{\psi}(p) e^{ipx/\hbar} \, \mathrm{d}p ~=~ \int_{\mathbb{R}} p \, \tilde{\psi}(p) \, e^{ipx/\hbar} \, \mathrm{d}p \tag{2} $$
which is okay because we can expand the wavefunction on the position space as a sum of wavefunctions on the momentum space using the Fourier transform on $\psi(x) .$
Using this result, we have that
$$ \langle \psi \vert \hat{p} \vert \psi \rangle ~=~ \int_{\mathbb{R}} \left( \int_{\mathbb{R}} \tilde{\psi}^*(p') \, e^{ip'x/\hbar} \mathrm{d}p' \right) \left( \int_{\mathbb{R}} p \, \tilde{\psi}(p) \, e^{ipx/\hbar} \mathrm{d}p \right) \mathrm{d}x \tag{3} $$
However, I don't get why the next two steps are mathematically correct and how he moves the integration signs:
$$ \begin{align} \langle \psi \vert \hat{p} \vert \psi \rangle &= \int_{\mathbb{R}} \int_{\mathbb{R}} p\, \tilde{\psi}^*(p')\, \tilde{\psi}(p) \left( \int_{\mathbb{R}} e^{i(p-p')x/\hbar} dx\right) \, \mathrm{d}p' \, \mathrm{d}p \tag{4} \\[5px] &= \int_{\mathbb{R}} \int_{\mathbb{R}} \delta(p-p') \,p\, \tilde{\psi}^*(p')\, \tilde{\psi}(p) \, \mathrm{d}p \, \mathrm{d}p' \tag{5} \\[5px] &= \int_{\mathbb{R}} p \vert \tilde{\psi}(p) \vert^2 \, \mathrm{d}p \tag{6} \\[5px] &= \langle p \rangle \tag{7} \end{align} $$
Eq. (7) obviously follows from Eq. (6), because the expectation value of a random variable is equal to the integral of that variable times the probability density distribution, which is exactly what $\vert\tilde{\psi}(p)\vert^2$ is. But how does he get to Eq. (6)?
Question: How do we get Equations (5) and (6) starting from Equation (4)?