searching and sorting the process starts by finding the smallest value in the sequence and swaps it with the value in the first position of the sequence the second smallest value is then found and swapped with the value in the second position this process continues positioning each successive value by selecting them from those not yet sorted and swapping with the values in the respective positions figure shows the results after each iteration of the algorithm when applied to the sample array of integers the grayed boxes represent those items already placed in their proper position while the black boxes show the two values that are swapped the selection sortwhich makes passes over the array to reposition valuesis also ( the difference between the selection and bubble sorts is that the selection sort reduces the number of swaps required to sort the list to (ninsertion sort another commonly studied sorting algorithm is the insertion sort continuing with our analogy of sorting set of playing cards to illustrate the sorting algorithmsconsider five cards stacked in deck face up the deck we pick up the top card from the deck and place it in our hand our hand the deck since this is the first cardthere is no decision to be made as to its position we again pick up the top card from the deck and compare it to the card already in our hand and insert it into its proper sorted position our hand the deck after placing the into our handthe process is repeated this timewe pick up the and find its position within our hand and insert it in the proper place our hand the deck