There are several ways of sorting arrays..
I'll post one here, so you'll have an idea:
Code:
#include <stdio.h>
#define MAX 10
int main(void)
{
int array[MAX] = {2, 3, 4, 1, 7, 8, 9, 6, 0, 5};
int backup;
int sorted = 0; /*0 = false, 1 = true, if array is sorted -> sorted = true */
int i;
// compare array[i] to array[i + 1], if array[i] > array[i + 1], switch them
while(!sorted) {
sorted = 1;
for (i = 0; i < MAX - 1; i++)
if (array[i] > array[i + 1]) { /* switching values */
backup = array[i];
array[i] = array[i + 1];
array[i + 1] = backup;
sorted = 0;
}
}
for(i = 0; i < MAX; i++)
printf("%d\n", array[i]);
return 0;
}