-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lststr_sortrev.c
42 lines (39 loc) · 1.36 KB
/
ft_lststr_sortrev.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lststr_sortrev.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: malexand <malexand@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/17 00:27:46 by skyzie #+# #+# */
/* Updated: 2017/02/16 17:34:23 by malexand ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lststr_sortrev(t_list *lst)
{
char *temp;
t_list *tmplst;
t_list *start;
start = lst;
tmplst = lst;
if (!lst)
return (lst);
while (lst)
{
while (tmplst)
{
if (ft_strcmp(lst->content, tmplst->content) < 0)
{
temp = lst->content;
lst->content = tmplst->content;
tmplst->content = temp;
ft_swap(&lst->content_size, &tmplst->content_size);
}
tmplst = tmplst->next;
}
lst = lst->next;
tmplst = lst;
}
return (start);
}