using System; namespace InsertionSort { class Program { static int[] numbers = { 4, 1, 6, 3, 7, 3, 7 }; // defining an array of ints static void Main(string[] args) { Insertion(numbers); // call the subroutine } static void Insertion(int[] list) { for (int x = 0; x < list.Length; x++) // for each value in list { int temp = list[x]; // set temporary variable for the value at X int y = x - 1; // look at the value before that while (y >= 0 && temp < list[y]) // if that value is greater than 0 and less than X { list[y + 1] = list[y]; // set the value after it (basically X) to that value y = y - 1; // go to the value before that } list[y + 1] = temp; // set the original y value to X } for (int z = 0; z < list.Length; z++) // print out the sorted array { Console.Write("{0}", list[z]); } } } }