Minimize function 
$f$ is a density function given by $f(x|\theta)= (1/2)e^{-|x-\theta|}.$ The function $h$ is defined by $h(\theta) = \sum_{i=1}^n |x_i-\theta|.$ Show that if $n$ is even $h$ minimizes for all $[x_{n/2},x_{n/2+1}]$, and if $n$ is odd then $h$ minimizes in $x_{n/2+1}$.

I'm considering the even case, but I got stuck at the end.
I would rather write $h(\theta) = \sum_{i=1}^n \sqrt{(x_i-\theta)^2}.$ Then I could find $h'$ because $(\sqrt{(x_i-\theta)^2})'= (1/2)((x_i-\theta)^2)^{-1/2}(-2x_i+2\theta)=\displaystyle\frac{\theta-x_i}{\sqrt{(x_i-\theta)^2}}=\displaystyle\frac{\theta-x_i}{|x_i-\theta|}.$
But now how do I prove the statement? Since $h'(\theta) = \displaystyle\sum_{i=1}^n \displaystyle\frac{\theta-x_i}{|x_i-\theta|}$ In order to have $h'=0$ it would have to be $\displaystyle\sum_{i=1}^n \theta-x_i=n\theta - \displaystyle\sum_{i=1}^n x_i = 0$. Then when we have values in $[x_{n/2},x_{n/2+1}]$ and $n$ is even it should be $\displaystyle\sum_{i=1}^n x_i=n\theta$. Even when if it is done, it remains to show that it is in fact a minima and not a maxima.
I'm not sure how to proceed.

Observe that $$\frac{d}{dx}|x|=\mbox{sgn}(x),$$ where $\mbox{sgn}(x)=1$ when $x>0$, $\mbox{sgn}(x)=-1$ when $x<0$, and $\mbox{sgn}(0)=0$ by definition.
Therefore, $$h'(\theta)=\sum_{i=1}^{n}\mbox{sgn}(\theta-x_i).$$
Let $y_i$ be the sorted values of $x_i$ such that $y_1 \le y_2 \le \cdots \le y_n$. Then, 
$$h'(\theta)=\sum_{i=1}^{n}\mbox{sgn}(\theta-y_i).$$
Observe that $\mbox{sgn}(z)$ can take on only three values: $0$, $1$ or $-1$. 
It is easy to observe that, for odd $n$, $h'(\theta)=0$ when $\theta = y_{(n+1)/2}$, the median of $x_i$'s (due to $(n-1)/2$ positive and negative $1$s). For even $n$, if $y_{(n/2)} < \theta <y_{(n/2+1)}$ then $h'(\theta)=0$ because of the summation of $n/2$ positive and negative $1$s.
