Why is $\int_{-\infty}^\infty |g(x)|\,dx = \int_0^\infty \mu(\{x : |g(x)| \ge t\})\,dt$ true? Why do we have the following equality$$\int_{-\infty}^\infty |g(x)|\,dx = \int_0^\infty \mu(\{x : |g(x)| \ge t\})\,dt,$$where $\mu$ is Lebesgue measure?
 A: Observe
\begin{align}
\int^\infty_0 \mu\{x \mid |g(x)|\geq t\}\ dt =& \int^\infty_0 \int^\infty_{-\infty} \chi_{\{x \in \mathbb{R} \mid |g(x)| \geq t\}}\ dxdt\\
=&\  \int^\infty_{-\infty} \int^\infty_0\chi_{\{x \in \mathbb{R} \mid |g(x)| \geq t\}}\ dtdx\\
=&\ \int^\infty_{-\infty} \int^{|g(x)|}_0 \ dtdx \\
=&\ \int^\infty_{-\infty} |g(x)|\ dx.
\end{align} 
Edit: Note that the interchanging of integrals are allowed because everything is non-negative. 
A: We claim that for a nonnegative measurable function $g:\Bbb{R}\to[0,\infty)$,
$$
\int_\Bbb{R}g(x)\ d\mu(x)=\int_{[0,\infty)}\mu(\{x\in\Bbb{R}\mid g(x)\geq s\}) \ d\mu(s).
$$
This is a good example of applications of the Fubini-Tonelli's Theorem. 
Let $\nu:=g_*\mu$ be the pushforward of $\mu$, i.e., $\nu=\mu\circ g^{-1}$. Then
$$
\int_\Bbb{R}g(x)\ d\mu(x)=\int_{[0,\infty)}x\ d\nu(x).
$$
Note that
$$
\begin{align*}
\int_{[0,\infty)}x\ d\nu(x)&=\int_{[0,\infty)}\left(\int_{[0,\infty)}1_{[0,x]}(y)\ d\mu(y)\right)\ d\nu(x)\\
&=\int_{[0,\infty)} \left(\int_{[0,\infty)}1_{[y,\infty]}(x)\ d\nu(x)\right)\ d\mu(y)\\
&=\int_{[0,\infty)} \nu([y,\infty))\ d\mu(y)\\
&=\int_{[0,\infty)} \mu\circ g^{-1}([y,\infty))\ d\mu(y)\\
&=\int_{[0,\infty)}\mu(\{x\in\Bbb{R}\mid g(x)\geq y\}) \ d\mu(y).
\end{align*}
$$
