Check out example codes for "quick sort predefined function in c++". It will help you in understanding the concepts better.

Code Example 1

#include <cstdlib>

//declare compare
int compare(const void* a, const void* b)
{
	const int* x = (int*) a;
	const int* y = (int*) b;

	if (*x > *y)
		return 1;
	else if (*x < *y)
		return -1;

	return 0;
}

//fuction used
qsort(arr,num,sizeof(int),compare);

Learn ReactJs, React Native from akashmittal.com