Sat. Jan 21st, 2023

Sorting Algorithms

Sorting algorithms are used to ensure that lists of data are organised – for example, a list of numbers are rearranged so that they run from lowest to highest (ascending) or highest to lowest (descending).

For the purposes of this course you should be familiar with:

Why are sorting algorithms necessary?

There are many occasions when one needs to search through a set of data to look for something. For example, whether a name appears in a list or looking up the details of an order from a sales system.

In small data sets, it is possible to simply scan through each entry until to find what you are looking for – this is how the linear search works. With larger data sets, and in situations where this must happen regularly, it is not efficient, and there are much faster ways to find information. However, these more efficient search algorithms require something that a linear search doesn’t: the data must be ordered (numerically or alphabetically).

For this reason, there are many different algorithmic approaches to sorting data. They have their own advantages and disadvantages – how well do they scale as the data set increases in size and how easy are they to program being two key issues.


This page contains an excellent animation showing how efficient different sorting algorithms are in comparison to each other with different data sets.