34 lines
1.2 KiB
C
34 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_radix.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/11/15 18:16:31 by cchauvet #+# #+# */
|
|
/* Updated: 2022/11/28 16:29:46 by cchauvet ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "pushswap.h"
|
|
|
|
void ft_radix_sort(int *tab_a, int *tab_b)
|
|
{
|
|
int i;
|
|
|
|
while (ft_bit_finder(ft_get_bit_max(tab_a), 1) != (int) sizeof(int) * 8 - 1)
|
|
{
|
|
i = 0;
|
|
while (i < ft_tablen(tab_a))
|
|
{
|
|
if (((tab_a[i] >> (sizeof(int) * 8 - 1)) & 1) == 0)
|
|
ft_ra(tab_a);
|
|
else
|
|
ft_pa(tab_a, tab_b);
|
|
i++;
|
|
}
|
|
while (0 < ft_tablen(tab_b))
|
|
ft_pb(tab_b, tab_a);
|
|
}
|
|
}
|