Fix median algorithm

I had reversed a <= check