Median along arbitrary dimensions, fixes #6648

Simple fix for https://github.com/JuliaLang/julia/issues/6648