Sorting Techniques
Write the classic sorting algorithms, explain their speed and stability, and pick the right one for a job.
4 trail maps · 8 articles · 25 min reading, plus a task to try in each article
Last verified
Start the trail
First up: Sort with Python, 3 min
Before you start
- Write a short Python script.(opens in a new tab) Every example is Python.
- Read a loop and a function. You should be comfortable with for loops, while loops and recursion basics.
Trail maps
- Simple sorts 3 articles
Sort with Python, then write your first sorts by hand.
- Faster sorts 2 articles
Split the problem to sort large lists quickly.
- Choosing a sort 2 articles
Understand stability and measure real speed.
- Proof project 1 article
Put the trail together and prove you reached the destination.
- Article 1: Sort with Python3 min. Part of Simple sorts. Start here. Done.
- Article 2: Selection sort3 min. Part of Simple sorts. Done. Learn first: Sort with Python.
- Article 3: Insertion sort4 min. Part of Simple sorts. Done. Learn first: Selection sort.
- Article 4: Merge sort4 min. Part of Faster sorts. Done. Learn first: Insertion sort.
- Article 5: Quicksort4 min. Part of Faster sorts. Done. Learn first: Merge sort.
- Article 6: Stable sorting and keys2 min. Part of Choosing a sort. Done. Learn first: Sort with Python.
- Article 7: Compare sorting speeds3 min. Part of Choosing a sort. Done. Learn first: Quicksort, Stable sorting and keys.
- Article 8: Sort a list of records2 min. Part of Proof project. Done. Learn first: Compare sorting speeds.
Simple sorts
Faster sorts
Choosing a sort
Proof project
After this trail
- Searching(opens in a new tab) Binary search needs sorted data, so it is the natural next step.
- Heaps and priority queues(opens in a new tab) Get the smallest item without sorting everything.
- Algorithm analysis Learn to compare algorithms by how their work grows with input size.