Check out example codes for "qsort in c". It will help you in understanding the concepts better.

Code Example 1

#include <stdlib.h>
int cmpfunc (const void * a, const void * b) {
   return ( *(int*)a - *(int*)b );
}

int main () {
//n is number of elements in arr(size f that arr)
   qsort(arr, n, sizeof(int), cmpfunc);
   }

Learn ReactJs, React Native from akashmittal.com