Sorting Algorithm Lab

Watch arrays sort themselves step by step: compare, swap, partition, merge, and finish.

← Back to Portal

Bubble Sort

Step through comparisons
Ready 0 / 0
Generate an array, pick an algorithm, then press Play or Next.

How sorting works

Compare

Most sorting algorithms repeatedly ask a simple question: which of these two values should come first?

Move

After comparing, the algorithm swaps, shifts, partitions, or writes values into better positions.

Finish

Eventually every value is in order. Some algorithms prove sorted regions as they go; others rebuild the whole array.

Divide & Conquer

Some algorithms split a big problem into smaller problems, solve those, then combine the answers. Merge Sort and Quick Sort both use this idea.

Tradeoffs

Fast algorithms often use more memory, recursion, or coordination. A simple algorithm may be easier to understand but slower on big arrays.

Teen-friendly explanation

Bubble Sort

Imagine bubbles rising in water. Bigger values keep swapping to the right until they “float” to the end.

Selection Sort

Selection Sort keeps finding the smallest remaining value and placing it into the next open spot.

Quick Sort

Quick Sort picks a pivot, moves smaller values to one side and larger values to the other, then repeats on each side.

Divide and Conquer

This means “split, solve, combine.” Instead of sorting one huge list directly, split it into smaller lists, sort those, then combine the results.

Try this

  • Use a small array first, like 12 items.
  • Press Next slowly and read each step.
  • Compare Bubble Sort vs Quick Sort on 50 items.
  • Try Reverse Sorted to stress-test simple algorithms.