In the previous chapter, you read about ordered arrays and binary trees. In particular, you learned how to work with ordered arrays of pointers to insert, delete, and find individual items.
In this chapter, you will learn methods to bring order to unordered arrays.
Insertion Sort
The simplest way to sort an array is to go through its elements one by one and move them to their correct positions. This is what you do when you sort the cards in your hand while playing a card game.
Listing 9-1 shows how easy it is to apply insertion sort to an array of pointers.
Listing 9-1. sort_insertion()
1. //-------------------------------------------------------------- ...