#include <stdio.h>
int len(char* str)
{
int i;
i = 0;
while (str[i] != '\0')
{
i++;
}
return i;
}
int ft_strcmp(char *s1, char *s2)
{
int i;
int big_len;
i = 0;
big_len = 0;
if(len(s1) > len(s2))
big_len = len(s1);
else
big_len = len(s2);
while (s1[i] != '\0' || s2[i] != '\0' || i < big_len)
{
if (s1[i] != s2[i])
return s1[i] - s2[i];
i++;
}
return 0;
}
void swap(char** c1, char** c2)
{
char* t;
t = *c1;
*c1 = *c2;
*c2 = t;
}
int main(int argc, char* argv[])
{
int i;
int j;
i = 1;
while (i < argc)
{
j = i + 1;
while (j < argc)
{
if (ft_strcmp(argv[i], argv[j]) > 0)
swap(&argv[i], &argv[j]);
j++;
}
i++;
}
i = 1;
while (i < argc)
{
write(1, argv[i], len(argv[i]));
i++;
}
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: