Gah! Bubble sort? If this is for a class, please tell your professor that there is absolutely no use for it. It's very inefficient and hard to implement. If you are doing this for yourself, I would strongly recommend switching to

**Insertion Sort**. It has O(n^2) worst case performance (in theory the same as bubble sort, but in reality bubble sort is slower than even selection sort, which is slower than insertion sort). If you are required to have some sort of "bubbling up" effect, use heap sort. Heap sort is O(nlog(n)) performance (even better than insertion sort), but is a more advanced algorithm to implement.