42-archive/libft/srcs/sstr/ft_sstrsort.c
2017-03-31 18:40:30 +02:00

33 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_sstrsort.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 18:03:37 by jhalford #+# #+# */
/* Updated: 2016/11/23 14:46:54 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_sstrsort(char **list, int (*cmp)())
{
int i;
char *tmp;
i = 0;
while (list[i] && list[i + 1])
{
if ((*cmp)(list[i], list[i + 1]) > 0)
{
tmp = list[i];
list[i] = list[i + 1];
list[i + 1] = tmp;
i = 0;
}
else
i++;
}
}