Bubble sort implemented using the template pattern.