Run to execute this JavaScript code for real (output appears here).
Ready.
Repeatedly compares adjacent elements and swaps them when they are out of order, so the largest unsorted value bubbles to the end after every pass. Press Run (Ctrl + Enter) to animate, or Step forward (F10) to go one event at a time.
Step
1 / 49
Line (JavaScript)
—
main (no active function frames)
No counted operations yet.
[5, 3, 8, 1, 2]