From 61c619f2d24cadd53defe1cfa74b71f644c49010 Mon Sep 17 00:00:00 2001 From: Dominik Kaiser Date: Wed, 17 Apr 2024 10:51:01 +0200 Subject: [PATCH] Add presorting All entries that are not in order will be pushed into b. If the entry is larger than our pivot, it will be pushed to the bottom, else the top of b. --- sorting.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/sorting.c b/sorting.c index 8f5d31f..ca21757 100644 --- a/sorting.c +++ b/sorting.c @@ -6,13 +6,38 @@ /* By: dkaiser a->size; + pivot = size / 2; + max = data->a->stack[0]; + while (size--) + { + if (data->a->stack[0] < max) + { + run_command(data, PB); + if (data->b->stack[0] > pivot) + run_command(data, RB); + } + else + { + max = data->a->stack[0]; + run_command(data, RA); + } + } +} +void stack_sort(t_psdata *data) +{ + presort(data); } -- 2.47.2