Putting a data set into some kind of logical order is a very common task. For example, the binary search algorithm discussed in the search section requires an ordered data set to work.
Numbered data sets could be ordered in ascending (lowest to highest) or descending (highest to lowest) order. Text data sets could be ordered in alphabetic order.
No matter the criteria you use for sorting, you can use the same sorting algorithms to carry it out. As with any other task, there are several ways you can sort things, but for this syllabus you will only be required to learn two:
- Bubble Sort
- Merge Sort
Each of these will be described in this section along with their strengths and weaknesses.