Easy Sorting

Bubble Sort

Receives an array of integers and sorts it in ascending order using bubble sort. It makes repeated passes over the unsorted portion: on each pass it compares every adjacent pair — if the left value is greater than the right, they are swapped — so the largest unsorted value bubbles to its final position at the end. Each subsequent pass covers one fewer element because the last position of the previous pass is already settled; an early-exit check stops the algorithm as soon as a full pass makes no swaps, because the array is already in order. Returns a new array with the values in ascending order.

Visualization

Input

Algorithm code

Custom input

Saved inputs

References