title: Convert Months To Number Equivalent To Be Used In Quicksort
body: <p>I have some months read into an array from an external text file and I need to convert the months to an array that holds the value equivalent of the months e.g. January = 1, February = 2 etc. So that they can then be put through Quicksort.</p>
  
  <pre><code> public static void Main(string[] args)
      {
          //Read external files into arrays.
          string[] Month = File.ReadLines(@"Month.txt").ToArray();
          string[] Year = File.ReadLines(@"Year.txt").ToArray();
  
          //Convert arrays from string to double to be used in sort.
          double[] YearSort = Array.ConvertAll(Year, double.Parse);
  
          int UserInput1;
  
          //Create new array that will hold selected array to be used in sort. 
          double[] data = new double[1022];
          //Prompt user to select action. 
      Console.WriteLine("Press 1 to Sort by month or 2 to sort by year.");
       UserInput1 = Convert.ToInt32(Console.ReadLine());
  
      if(UserInput1 == 1)
      {
          Array.Copy(Month,data,1022);
          QuickSort(data); 
           for (int i = 0; i &lt; 1022; i++)
    Console.WriteLine(data[i]);
    Console.WriteLine();
      }
      else if (UserInput1 == 2)
      {
          Array.Copy(YearSort,data,1022);
          QuickSort(data); 
           for (int i = 0; i &lt; 1022; i++)
    Console.WriteLine(data[i]);
    Console.WriteLine();
      }
      else
      {
          Console.WriteLine("Please try again and select a valid option");
      }
      }
  
  static int MonthToDouble( string Month )
          {
              int NewMonth = 0;
  
              switch(Month)
              {
                  case "January":
                  case "january":
                      NewMonth = 1;
                      break;
                  case "February":
                  case "february":
                      NewMonth = 2;
                      break;
                  case "March":
                  case "march":
                      NewMonth = 3;
                      break;
                  case "April":
                  case "april":
                      NewMonth = 4;
                      break;
                  case "May":
                  case "may":
                      NewMonth = 5;
                      break;
                  case "June":
                  case "june":
                      NewMonth = 6;
                      break;
                  case "July":
                  case "july":
                      NewMonth = 7;
                      break;
                  case "August":
                  case "august":
                      NewMonth = 8;
                      break;
                  case "September":
                  case "september":
                      NewMonth = 9;
                      break;
                  case "October":
                  case "october":
                      NewMonth = 10;
                      break;
                  case "November":
                  case "november":
                      NewMonth = 11;
                      break;
                  case "December":
                  case "december":
                      NewMonth = 12;
                      break;
              }
  
              return NewMonth;
          }
  
          static string DoubleToMonth(double Month)
          {
              string NewMonth = "";
  
              switch ((int)Month) 
              {
                  case 1:
                      NewMonth = "January";
                      break;
                  case 2:
                      NewMonth = "February";
                      break;
                  case 3:
                      NewMonth = "March";
                      break;
                  case 4:
                      NewMonth = "April";
                      break;
                  case 5:
                      NewMonth = "May";
                      break;
                  case 6:
                      NewMonth = "June";
                      break;
                  case 7:
                      NewMonth = "July";
                      break;
                  case 8:
                      NewMonth = "August";
                      break;
                  case 9:
                      NewMonth = "September";
                      break;
                  case 10:
                      NewMonth = "October";
                      break;
                  case 11:
                      NewMonth = "November";
                      break;
                  case 12:
                      NewMonth = "December";
                      break;
              }
  
              return NewMonth;
          }
  
   //QuickSort for double data values are in ascending order. 
   public static void QuickSort(double[] data)
   {
   Quick_Sort(data, 0, data.Length - 1);
   }
  public static void Quick_Sort(double[] data, int left, int right)
   {
   int i, j;
   double pivot, temp;
   i = left;
   j = right;
   pivot = data[(left + right) / 2];
   do
   {
   while ((data[i] &lt; pivot) &amp;&amp; (i &lt; right)) i++;
   while ((pivot &lt; data[j]) &amp;&amp; (j &gt; left)) j--;
   if (i &lt;= j)
   {
   temp = data[i];
  data[i] = data[j];
  data[j] = temp;
  i++;
  j--;
   }
   } while (i &lt;= j);
   if (left &lt; j) Quick_Sort(data, left, j);
   if (i &lt; right) Quick_Sort(data, i, right);
   }          
  }
  </code></pre>