Python implementation of the quickselect algorithm