Optimise bubble sort