01How it works
Walk the array pairwise and swap any two neighbors that are in the wrong order. Each full pass bubbles the largest remaining element to the end; after n−1 passes the array is sorted. An early-exit flag lets an already-ordered input finish in a single pass.