Skip to main content
Logo image

Section 22.10 Implementing Sort Arrays

Subsection 22.10.1 Printing

When printing out arrays the order of whose elements is given by a sort array, it is important to not only pass the array itself to the printing routine but also include the sort array (how else would the routine be able to know the correct order).

Activity 22.5.

Please write a function printArray(), to which you pass the number of elements in your list to be sorted as well as the list and the sort array. The function should print the list in the order defined by the sort array.

admin.....open in new window

When you are done, please paste your code into the code submission box below:

Subsection 22.10.2 Sorting

When sorting arrays using a sort array, when your code finds values whose locations should be swapped, instead of swapping the values in the array, swap their respective elements of the sort array.

Activity 22.6.

Please implement the function sortArray(), to which you pass the number of elements in your list to be sorted, the unsorted array as well as a sort array, and which sorts the array, using bubble sort, by making changes only to the sort array.

admin.....open in new window

When you are done, please paste your code into the code submission box below: