def partition_array(nums, k):
    """
    Partition given array (like quick sort)

    :param nums: given array
    :type nums: list[int]
    :param k: partition value
    :type k: int
    :return: the partitioning index
    :rtype: int
    """
    left = 0
    right = len(nums) - 1
    while left <= right:
        while left <= right and nums[left] < k:
            left += 1
        while left <= right and nums[right] >= k:
            right -= 1
        if left <= right:
            nums[left], nums[right] = nums[right], nums[left]
            left += 1
            right -= 1
    return left