finalized bubble sort algorithm