// Comparing function:
// Returns a positive number if a is greater than b
// Returns a negative number if a is less than b
// Returns 0 if a is equal to b
int compare(const void *a, const void *b) {
int *valA = a;
int *valB = b;
return *valA - *valB;
}
int main() {
// Create an array
int myArray[] = {20, 32, 5, 2, 24, 15};
int size = sizeof(myArray) / sizeof(myArray[0]);
// Sort the values in the array
qsort (myArray, size, sizeof(myArray[0]), compare);
// Display the values of the array
for(int i = 0; i < size; i++) {
printf("%d ", myArray[i]);
}
return 0;
}