Zebra0.com

cpp templatesA Template bubble sort

A Template bubble sort

Here we have written a Template bubble sort. This is an inefficient sort to start with, and here we have not even optimized it to stop sorting when there are no swaps in a single pass. However, I wanted to keep it as simple as possible to illustrate using the Temple to write a function with arrays.

Note that arrays are ALWAYS passed by reference and we do not need the &. However, we do need to pass the size of the array as an argument.