Integrating the sign function Let $sgn(t)=1$ when $t>0$, $sgn(t)=0 $ when $t=0$, and $sgn(t)=-1$ when $t<0$.
Show that $$S(x):=\int_{-1}^{x}sgn(t)dt$$ is equal to $|x|-1$ for all $x\in[-1,1]$
My attempt:
If $x=-1$, then
$S(-1)=\int_{-1}^{-1}sgn(t)dt=0=|-1|-1=|x|-1.$

If $x=0$, then
$S(0)=\int_{-1}^{0}sgn(t)dt=\int_{-1}^{0}-1\cdot dt=-\int_{-1}^{0}1\cdot dt=-1(0--1)=-1=|x|-1$

If $x=1$ then
$S(1)=\int_{-1}^{1}sgn(t)dt=\int_{-1}^{0}sgn(t)dt+\int_{0}^{1}sgn(t)dt=-1+\int_{0}^{1}1\cdot dt=-1+(1-0)=0=|x|-1$.

If $x\in(-1,0)$
$S(x)=\int_{-1}^{x}sgn(t)dt=\int_{-1}^{x}-1\cdot dt=-\int_{-1}^{x}1\cdot dt=-1(x--1)=-x-1$

If $x\in(0,1)$ then
$S(x)=\int_{-1}^{x}sgn(t)dt=\int_{-1}^{0}sgn(t)dt+\int_{0}^{x}sgn(t)dt=-1+\int_{0}^{x}1\cdot dt=-1+(x-0)=-1+x$.

Is my solution correct? Does it show what I was asked to prove? Thanks!

It is correct, but you could have saved a lot of work by showing that $|x|'=\operatorname{sgn}(x)$ (with an arbitrary choice for $x=0$, which doesn't matter since isolated discontinuities can be ignored in integration) and then applying the fundamental theorem of calculus.
