functional bubblesort