Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=ik), | intent(inout) | :: | arr(:) | |||
integer, | intent(in) | :: | low | |||
integer, | intent(in) | :: | high |
function partition_integer(arr, low, high) result(pivot_index) integer(ik), intent(inout) :: arr(:) integer, intent(in) :: low, high integer :: pivot_index integer(ik) :: pivot, temp integer :: i, j pivot = arr(high) i = low - 1 do j = low, high - 1 if (arr(j) <= pivot) then i = i + 1 temp = arr(i) arr(i) = arr(j) arr(j) = temp end if end do temp = arr(i + 1) arr(i + 1) = arr(high) arr(high) = temp pivot_index = i + 1 end function partition_integer