DSA Factory
All free lessons
Level 2 · Core

Free Sorting lessons

8 lessons, about 69 minutes in all. Each teaches one idea with a visual, then gives you one problem built for it. Read the lessons here, then create a free account to solve the problems and keep your progress.

Stage 0Sort it first

  1. Position is rankSort with one line, then read the answer off an index.7 min
  2. Neighbours after sortingOnce sorted, the closest values sit side by side.8 min
  3. Choose what to sort bySort by a rule you pick, and say how to break ties.10 min
  4. Sort, then two pointersWhen positions don't matter, sort first and walk inward.10 min

Stage 1Comparing and swapping

  1. Swap your way alongWalk the list once, swapping any pair that's out of order.8 min
  2. Pick the smallest, then move onEach pass finds the smallest value left and swaps it to the front.8 min
  3. Slide it into placePush bigger values one step right until the new one fits.9 min
  4. How far from sorted?Compare against the sorted version to see what's really out of place.9 min

There’s more after this

These are the opening stages of Sorting. The full path climbs on to harder problems and a mastery test. Create a free account and we’ll keep your place.

Start the full path free