I'm having trouble understanding why it is that when I try to calculate $\int_{0}^{\pi}|\sin(x)|dx$ from it's indefinite integral I seem to get the wrong result of $0$.
Of course $|\sin(x)| = \sin(x) $ on $[0, \pi]$ so I know the result should be $2$. But considering the indefinite integral
$\int |\sin(x)| = -\cos(x)sgn(\sin(x))$
($sgn$ is the sign function) I use some fallacious reasoning to conclude that
$\int_{0}^{\pi}|\sin(x)|dx = [-\cos(x)sgn(\sin(x))]_{0}^{\pi} = -(-1)(0) -(-1)(0)) = 0$
I think the problem is how I use the sign function but as far as I know $sgn(\sin(0)) = sgn(\sin(\pi)) = 0$ and $|\sin(x)| $ is continuous on $[0, \pi]$. What am I doing wrong here?