An improved bubble sort algorithm