character in the array one character by itself is already sorted then we consider the next character in the array if it is smaller than the firstwe swap them next we consider the third character in the array we swap it leftward until it is in its proper order with the first two characters we then consider the fourth characterand swap it leftward until it is in the proper order with the first three we continue in this manner with the fifth integerthe sixthand so onuntil the whole array is sorted mixing this informal description with programming constructswe can express the insertion-sort algorithm as shown in code fragment code fragment high-level description of the insertion-sort algorithm this is nicehigh-level description of insertion-sort it also demonstrates why this algorithm is called "insertion-sort"--because each iteration of the main inserts the next element into the sorted part of the array that comes before it before we can code this description uphoweverwe need to work out more of the details of how we do this insertion task diving into those details bit morelet us rewrite our description so that we now use two nested loops the outer loop will consider each element in the array in turn and the inner loop will move that element to its proper location with the (sortedsubarray of characters that are to its left refining the details for insertion-sort refining the detailsthenwe can describe our algorithm as shown in code fragment code fragment intermediate-level description of the insertion-sort algorithm