Bubble sort from Problem 2.2