Bubble sort is the easiest sorting idea to picture: keep swapping neighbours that are out of order until none are. It is a common written-test question because you can trace its passes by hand and reason about its swaps. Learn it to understand passes and the early stop when nothing swaps. In real code never write it, use Arrays.sort, which runs in O(n log n).