Tweaked implementation of median (fixes #7331)
Merge pull request #7337 from JuliaLang/dh/median2

Tweaked implementation of median (fixes #7331)