Sorting Algorithms
Introduction
How does one find the cheapest bottle on Amazon? Who’s the batsman with the most runs in IPL 2025? What algorithms do computers use to make such tasks easier? Sorting algorithms. A sorting algorithm is simply a set of step-by-step instructions that arranges a list of items into a specific order. For instance, we can order names alphabetically or numbers from smallest to largest. Computers use clever sorting methods to make data easier to search and organize—like finding a word in a dictionary or a record in a database. Sorting works by comparing or grouping items, and many methods exist—from simple to faster ones. Knowing how to choose and use the proper method helps computers run programs more efficiently and solve problems faster.
Materials required
- Homemade scale balance (2 cups, string, and a clothes hanger)
- Objects of different weights
- Index cards
- Hole puncher
- A Deck of Cards
- Pen, and Paper
Science behind it
We discuss three algorithms — Selection sort, Quicksort, and Radix sort. While Selection sort and Quicksort are based on comparisons, Radix sort involves grouping.
Selection sort is one of the simplest comparison-based sorting algorithms. Suppose we want to sort a shuffled list of numbers from 1 to 10. You want to find the smallest number in the list and swap it with the first number of the unsorted part of the list. You find the next smallest number and swap it again with the first unsorted number — gradually increasing the size of the sorted part of the list.
The idea behind Quicksort is as follows: Suppose we want to sort numbers from 1 to 10. Pick any one number in a list (called the pivot). Then, split the other numbers into two groups: the smaller ones go on the left, the bigger ones on the right. Now the pivot is in the exact spot where it should be in the final sorted list. Repeat the same process for the left and right groups until everything is in order.
Radix sort is a method for sorting numbers by looking at their digits. Instead of comparing numbers directly, it sorts them digit by digit. For example, first sort by the ones place, then the tens place, then the hundreds place, and so on, until all digits are covered. At each step, the numbers are grouped based on the digit being checked. By the end, the list is fully sorted.