median-of-medians selection algorithm for selection in javascript