Sorting Algorithms | Lilac & Logic

Lesson 01

How Sorting Algorithms Reorder Data

Sorting is basically taking an unsorted list of numbers or text and rearranging everything in order, usually from smallest to largest. It sounds simple, but different algorithms go about it in totally different ways.

1. Bubble Sort

Bubble sort is usually the first algorithm people learn because the idea is so basic. It goes down the list comparing neighbor items two at a time, swapping them if they are in the wrong order until everything is sorted.

How it works step by step:

  1. Start at the very beginning of your list with the first two items.
  2. Compare the left number with the right number.
  3. If the left number is bigger, swap their positions.
  4. Move over one spot to the right and repeat the comparison.
  5. Keep looping through the whole list until you can make a full pass without swapping anything.

Visualizer: Bubble Sort in Action

Here is a helpful animation showing how neighboring numbers compare and swap step by step until the entire array is arranged in order:

Animated visual breakdown showing numbers swapping step by step during Bubble Sort

Audio Overview: Visualizing Swaps

Listen to my quick breakdown on how array swaps and algorithm passes function during Bubble Sort:

Other Classic Sorting Methods

← Previous: Home Next Lesson: Searching →