Correct my code:
#include "../inc/push_swap.h"

void	ft_sort5_helper(int *a, int *b, int len_a, int len_b, int min_x, int min_z)
{
	int	posx;
	int	posz;

	posx = ft_find_min_pos_if(a, len_a, 0);
	posz = ft_find_min_pos_if(a, len_a, 1);
	if (posx > posz && len_a > 4)
	{
		while (a[0] != min_z)
		{
			if (posz > (len_a / 2 && len_b < 1))
				ft_rra(a, len_a);
			else if (posz < (len_a / 2))
				{ft_ra(a, len_a);
				printf("min_z: %d\n", min_z);
				ft_print_stack(a, b, len_a, len_b);}
		}
		if (a[0] > a[1] && a[0] == min_z && a[1] == min_x)
			ft_sa(a);
		else
			ft_pb(a, b, &len_a, &len_b);
	}	
	else if (posx < (len_a / 2 && len_b < 1))
		ft_rra(a, len_a);
	else
		ft_ra(a, len_a);
}

void	ft_sort5(int *a, int *b, int len_a, int len_b)

{
	int	min_x;
	int	min_z;
	int	i;

	i = len_a;
	while (len_a > 3)
	{
		min_x = ft_min_if(a, len_a, 0);
		printf("min_x: %d\n", min_x);
		min_z = ft_min_if(a, len_a, 1);
		if (ft_is_sorted(a, len_a))
			break ;
		while (a[0] != min_x)
		{
			ft_sort5_helper(a, b, len_a, len_b, min_x, min_z);
		}
		if (a[0] == min_x)
			ft_pb(a, b, &len_a, &len_b);
	}
	ft_sort3(a, len_a);
	if (len_b == 2 && b[0] < b[1])
		ft_sb(b);
	while (len_b > 0)
	{
		min_z = ft_max(b, len_b);
		if (b[0] == min_z)
			ft_pa(a, b, &len_a, &len_b);
		else if (b[len_b - 1] == min_z)
			ft_rrb(b, len_b);
		else if (b[0] < min_z && b[len_b - 1] < min_z)
		{
			ft_pa(a, b, &len_a, &len_b);
			if (a[0] > a[1])
				ft_sa(a);
		}
		else if (b[0] < min_z)
			ft_pa(a, b, &len_a, &len_b);
		else
			ft_rb(b, len_b);
	}
}
