global function quick_select(sequence s, integer k) integer left = 1, right = length(s), pos object pivotv, tmp while left