How bubble sort works

1/17
Step 1 of 17

The idea

  • Walk through the list, comparing each pair of neighbours.
  • If a pair is in the wrong order, swap it.
  • After each pass, the biggest remaining value is at the end.