Why did 5 and 6 compare two rounds?
Because in bubble sort, the first sort starts with the first number; while the second sort starts with the second number and compares it all the way to the end.
You may say, that's too simple, so let's make it more complicated. Given an array, perform a bubble sort.
comparing 1 and 7, 1 is smaller than 7, so the position of 1 remains the same and the array is.
Comparing 7 and 5, 7 is larger than 5, so 7 and 5 swap places and become ;
Comparing 7 and 4, 7 is larger than 4, so 7 and 4 swap places and become ;
The first sort is over, and some might say, 5 is bigger than 4. That's not a scientific bubble sort!
Because the bubble sort is not over, we just sorted from the first place to compare, and now we have to compare the second number.