from typing import List


def partition(array: List[float], left_pointer: int, right_pointer: int) -> int:
    """
    Select the last element of the array and divide the array between numbers smaller than the selected element
    and bigger than the selected element. Return the index of the pivot.
    """
    pivot_index = right_pointer
    pivot_value = array[pivot_index]

    right_pointer -= 1

    while True:
        while array[left_pointer] < pivot_value:
            left_pointer += 1

        while array[right_pointer] > pivot_value:
            right_pointer -= 1

        if left_pointer >= right_pointer:
            break
        else:
            array[left_pointer], array[right_pointer] = array[right_pointer], array[left_pointer]

# The final swap with the pivot
    array[left_pointer], array[pivot_index] = array[pivot_index], array[left_pointer]

    return left_pointer