-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv_sort_size.c
36 lines (33 loc) · 1.17 KB
/
v_sort_size.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
30
31
32
33
34
35
36
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* v_sort_size.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: glegendr <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/03/06 17:12:41 by glegendr #+# #+# */
/* Updated: 2018/03/06 17:12:42 by glegendr ### ########.fr */
/* */
/* ************************************************************************** */
#include "vector.h"
void v_sort_size(t_vec *vec)
{
int i;
int y;
if ((y = v_size(vec)) < 2)
return ;
while (y > 0)
{
i = 0;
while (i < v_size(vec) - 1)
{
if (v_size((t_vec *)v_get(vec, i)) <
v_size((t_vec *)v_get(vec, i + 1)))
{
v_swap(vec, i, i + 1);
}
++i;
}
--y;
}
}