Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Algorithms #12

Closed
reysand opened this issue Dec 12, 2020 · 0 comments
Closed

Algorithms #12

reysand opened this issue Dec 12, 2020 · 0 comments

Comments

@reysand
Copy link
Owner

reysand commented Dec 12, 2020

Bad algorithm in the get_ascii_sorted function

ft_ls/src/sorting.c

Lines 97 to 124 in bf9b147

void get_ascii_sorted(t_file **head)
{
t_file *list;
t_file **first;
t_file **second;
list = *head;
first = &(*head);
second = &(*first)->next;
while ((*first)->next)
{
ft_printf_fd(STDERR_FILENO, "%s ", (*first)->name);
ft_printf_fd(STDERR_FILENO, "%s\n", (*second)->name);
if (ft_strcmp((*first)->name, (*second)->name) > 0)
{
ft_printf_fd(STDERR_FILENO, "NEED_SWAP\t");
*first = (*first)->next;
ft_printf_fd(STDERR_FILENO, "%s ", (*first)->name);
ft_printf_fd(STDERR_FILENO, "%s\n", (*second)->name);
ft_printf_fd(STDERR_FILENO, "---open---\n");
ft_printf_fd(STDERR_FILENO, "%s ", (*first)->next->name);
ft_printf_fd(STDERR_FILENO, "%s\n", (*second)->next->name);
ft_printf_fd(STDERR_FILENO, "---close---\n");
}
first = &(*first)->next;
second = &(*second)->next;
}
}

@reysand reysand closed this as completed Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant