-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_sort_wordtab.c
40 lines (37 loc) · 1.22 KB
/
ft_sort_wordtab.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_sort_wordtab.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gfoote <gfoote@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/12 19:42:00 by gfoote #+# #+# */
/* Updated: 2019/04/11 12:14:47 by gfoote ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_sort_wordtab(char **tab)
{
int sorted;
int i;
char *tmp;
if (!tab || !*tab)
return ;
sorted = 0;
while (!sorted)
{
i = 0;
sorted = 1;
while (tab[i + 1])
{
if (ft_strcmp(tab[i], tab[i + 1]) > 0)
{
sorted = 0;
tmp = tab[i];
tab[i] = tab[i + 1];
tab[i + 1] = tmp;
}
i += 1;
}
}
}