Above, the bubbleSort() function iterates over the array in two for loops and compares the values of two items in the array at a time. It swaps the larger value the place of the smaller value and continues to do so in the loop until the “left” value is no longer greater than the “right” value (the array is fully sorted).
Algorithms for Beginners — Bubble Sort, Insertion Sort, Merge Sort
Erica Millado

Error in line number 28 it should be 1…arrayCount-2

Even the logs show that the last element was not sorted.

Like what you read? Give Urmil Setia a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.