Table of Contents
Sorting: given a sequence of data items in an unknown order, re-arrange the items to put them into ascending (descending) order by key.
Sorting algorithms have been studied extensively. There is no one best algorithm for all circumstances, but the big-O behavior is a key to understanding where and when to use different algorithms.
The insertion sort divides the list of items into a sorted and an unsorted region, with the sorted items in the first part of the list.
Idea: Repeatedly take the first item from the unsorted region and insert it into the proper position in the sorted portion of the list.