Refactored bubbleSort.