-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbubblesort.c
29 lines (27 loc) · 1.14 KB
/
bubblesort.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* bubblesort.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yst-laur <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/09 14:05:47 by yst-laur #+# #+# */
/* Updated: 2022/03/09 14:05:50 by yst-laur ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void bubble_sort(int *to_sort, int stack_size)
{
int j;
j = 0;
while (is_sorted(to_sort, stack_size) == 0)
{
while (j < (stack_size - 1))
{
if (to_sort[j] > to_sort[j + 1])
swap(&to_sort[j], &to_sort[j + 1]);
j++;
}
j = 0;
}
}