Isolated optimized bubble sort from bubble sort