From 05ba7c82a09e3e5485a91bc116e90f674f0308ec Mon Sep 17 00:00:00 2001 From: nova Date: Sun, 6 Jul 2025 07:04:19 +0200 Subject: [PATCH] added alhphasort --- sorting.c | 6 ++++++ sorting.h | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/sorting.c b/sorting.c index a5aabfb..b350b62 100644 --- a/sorting.c +++ b/sorting.c @@ -40,3 +40,9 @@ int sort_natural(const void *file0, const void *file1){ } } } + +int sort_alpha(const void *file0, const void *file1){ + char *file_name0 = ((file*)file0)->file_name; + char *file_name1 = ((file*)file1)->file_name; + return strcmp(file_name0, file_name1); +} diff --git a/sorting.h b/sorting.h index 8176473..711d7aa 100644 --- a/sorting.h +++ b/sorting.h @@ -1,8 +1,13 @@ #include #include #include "defines.h" +#ifndef SORTING_GUARD +#define SORTING_GUARD #include "sorting.c" +#endif void sort_dir(unsigned long *dir_length_width, char *dir_content); -int skip_hidden_files(const struct dirent *entry); +void sort_dir(unsigned long *dir_length_width, char *dir_content); +int sort_natural(const void *file0, const void *file1); +int sort_alpha(const void *file0, const void *file1);