fuckinlem_in/libft/srcs/ft_lstsort.c
Tanguy MAZE 54be2278c0 It finnaly kinda works
algorithm with no double nodes and nearly efficient enough
still some optimizations to find for --big-superposition maps
2019-04-18 20:18:50 +02:00

31 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstsort.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/10/01 11:54:22 by tmaze #+# #+# */
/* Updated: 2018/10/01 12:42:27 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstsort(t_list **lst, int (*f)(void *c1, void *c2), int rev)
{
t_list *sorted;
t_list *ind;
t_list *next;
ind = *lst;
sorted = NULL;
while (ind)
{
next = ind->next;
ft_lstaddsort(&sorted, ind, (*f), rev);
ind = next;
}
*lst = sorted;
}