Updated so export sorts the output

This commit is contained in:
Maix0 2024-08-15 14:12:46 +02:00
parent eaa381e8b7
commit 6909456ce5
5 changed files with 119 additions and 7 deletions

View file

@ -138,6 +138,7 @@ vec/buf_str/buf_str_functions3 \
vec/str/str \
vec/str/str_functions2 \
vec/str/str_functions3 \
vec/str/str_sort \
vec/u8/u8 \
vec/u8/u8_functions2 \
vec/u8/u8_functions3 \

View file

@ -2,6 +2,7 @@
headers = ["generic_sources/header/vec_C__PREFIX__.h__TEMPLATE__"]
sources = [
"generic_sources/src/vec/C__PREFIX__.c__TEMPLATE__",
"generic_sources/src/vec/C__PREFIX___sort.c__TEMPLATE__",
"generic_sources/src/vec/C__PREFIX___functions2.c__TEMPLATE__",
"generic_sources/src/vec/C__PREFIX___functions3.c__TEMPLATE__",
]

View file

@ -0,0 +1,41 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* best_move.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/29 20:04:33 by maiboyer #+# #+# */
/* Updated: 2024/01/31 14:25:00 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/types.h"
#include "me/vec/vec_str.h"
void vec_str_sort(t_vec_str *v,
t_vec_str_sort_fn is_sorted_fn)
{
t_usize sorted_part;
t_usize i;
t_str tmp;
if (v == NULL)
return;
sorted_part = v->len;
while (sorted_part > 0)
{
i = 0;
while (i < sorted_part - 1)
{
if (!is_sorted_fn(&v->buffer[i], &v->buffer[i + 1]))
{
tmp = v->buffer[i];
v->buffer[i] = v->buffer[i + 1];
v->buffer[i + 1] = tmp;
}
i++;
}
sorted_part--;
}
}