Added weighted median function and tests

Moving `v = v[mask]` and `wt = w.values[mask]` into the `if !all(mask)` block. The problem is that, while `v[mask]` has the same type as `v` for most AbstractVector types (at least until we switch to array views), that is not necessarily the case, and if `v` could have different types at runtime it will make the code below much slower.