In reply to raisins25.

If the median values are random (like in a simulation), it won't matter where any one value falls, but you can prevent the situation you describe by using the ideas in this blog post. Instead of comparing
if x < value then...
you can compare
if x < value+epsilon then...
where epsilon is a suitable small number.