def pivot(self, A, i, j):
        """
        Fix the pivot as the 1st element
        In the end, move the pivot to the end of closed set but still inside the closed set, in order to bisect

        pivoting algorithm:
        p | closed set | open set |
        | closed set p | open set |
        """
        p = i
        closed = p
        for ptr in xrange(i, j):
            if A[ptr] < A[p]:
                closed += 1
                A[ptr], A[closed] = A[closed], A[ptr]

        A[closed], A[p] = A[p], A[closed]
        return closed
dataset/ETHPy150Open algorhythms/LintCode/Median.py/Solution.pivot/original