Use the system quick sort
#include <stdio.h>
#include <stdlib.h>
int comp(const void *i, const void *j);
int main(void)
{
int sort[100], i;
/* set the array with random numer*/
for(i = 0; i < 100; i++)
sort[i] = rand();
/* call the quick sort */
qsort(sort, 100, sizeof(int), comp);
for(i = 0; i < 100; i++)
printf("%d\n", sort[ i ]);
return 0;
}
int comp(const void *i, const void *j)
{
return *(int*)i - *(int*)j;
}
Related examples in the same category