Activity 29.3.
Let’s upgrade our Bubble Sort code so that it can sort numbers in either ascending or descending order. The only thing that determines the sort order is the comparison
if (array[i] > array[i+1]). Write two callback functions:
-
int ascending(int a, int b)— returns 1 ifa > b -
int descending(int a, int b)— returns 1 ifa < b
Modify your Bubble Sort function to accept a callback as an extra argument, and inside the sort, replace your hardcoded
if statement with a call to that callback. Test your code to sort in both ascending and descending order.
Record your code below.

