/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_lstaddsort.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: tmaze +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/10/01 11:57:25 by tmaze #+# #+# */ /* Updated: 2018/10/01 12:40:27 by tmaze ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" void ft_lstaddsort(t_list **lst, t_list *new, int (*f)(void *c1, void *c2), int rev) { t_list *sorted; sorted = *lst; while (sorted && ((*f)(sorted->content, new->content) <= 0 || ((*f)(sorted->content, new->content) >= 0 && rev))) sorted = sorted->next; ft_lstadd(lst, new); }