title: Insertion sort algorithm c#
body: <p>I am trying to implement the Insertion sort in one of my programs. What I have been trying to create is a sorting program (in both ascending or descending order) However I have tried with algorithms such as quicksort and merge-sort, I am really new to c# and coding. The problem I am facing here is the fact that my files includes both a string of code, as well as a double/integer (example: 75.350, 74.430, Thursday, Friday) and since this algorithm is designed for integers. Is there a way to convert it please?</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.IO;
  
  namespace ConsoleApplication3
  {
      class Program
      {
          static void Main(string[] args)
          {
              StreamReader sh1Open = new StreamReader("c:..\\Files\\SH1_Open.txt");
              string Sh1OpenString = sh1Open.ReadToEnd();
  
  
              int[] x = { Convert.ToInt32(Sh1OpenString) };
              int j;
              int temp;
  
              for (int i = 1; i &lt; x.Length; i++)
              {
                  j = i - 1;
  
                  while (j &gt;= 0 &amp;&amp; x[j]&gt;x[j+1])
                  {
                      temp = x[j];
                      x[j] = x[j + 1];
                      x[j + 1] = temp;
  
                      j = j - 1;
                  }
              }
  
              for (int i = 0; i &lt; x.Length; i++)
              {
                  Console.WriteLine(x[i]);
              }
  
              Console.ReadKey();
  
          }
      }
  }
  </code></pre>