-
Notifications
You must be signed in to change notification settings - Fork 0
/
sort.c
43 lines (38 loc) · 1.31 KB
/
sort.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
37
38
39
40
41
42
43
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* sort.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mehtel <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/03/23 21:26:10 by mehtel #+# #+# */
/* Updated: 2021/03/23 21:26:33 by mehtel ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
void swap(int *fst, int *sec)
{
int tmp;
tmp = *fst;
*fst = *sec;
*sec = tmp;
}
void selection_sorting_sprite(float arr_val[], int arr_pos[], int n)
{
int i;
int j;
int min_idx;
i = -1;
while (++i < n - 1)
{
min_idx = i;
j = i;
while (++j < n)
{
if (arr_val[j] > (arr_val[min_idx]))
min_idx = j;
}
swap(&arr_pos[min_idx], &arr_pos[i]);
swap((int*)&arr_val[min_idx], (int*)&arr_val[i]);
}
}