implemented quickselect algorithm for axis medians