#include "libft.h" void ft_lstinsert(t_list **lst, t_list *new, int (*f)(t_list *a, t_list *b)) { if (!(*lst)) { *lst = new; return; } while ((*lst)->next && f(new, *lst) < 0) { lst = &(*lst)->next; } t_list *tmp = (*lst)->next; (*lst)->next = new; new->next = tmp; }