title: Using QuickSort to sort months in calendar order
body: <p>I am writing a program which needs to be capable of sorting weather data. One of the functionalities is that when sorting data by month, it has to sort months in order as they appear in calendar (if it's in ascending order, it has to be January, February, March and so on; not April, August, etc). </p>
  
  <p>The problem I am having is that the algorithm (QuickSort) does not quite sort the array the way I want it to.</p>
  
  <pre><code>public static void sortMonths(string[] month,int left,int right)
  {
      Dictionary&lt;string,int&gt; monthsDictionary = new Dictionary&lt;string,int&gt;()
      {
          {"January",1},
          {"February",2},
          {"March",3},
          {"April",4},
          {"May", 5},
          {"June", 6},
          {"July", 7},
          {"August", 8},
          {"September", 9},
          {"October", 10},
          {"November", 11},
          {"December", 12},
      };
  
      int i = left,j = right;
  
      string[] sortedMonth = month;
  
      string tempMonth;
  
      string pivot = sortedMonth[(i+j)/2];
  
      while(i&lt;=j)
      {
          while(monthsDictionary[sortedMonth[i]] &lt; monthsDictionary[pivot])
              i++;
          while(monthsDictionary[sortedMonth[j]] &gt; monthsDictionary[pivot])
              j--;
          if(i &lt;= j)
          {
              tempMonth = sortedMonth[i];
              sortedMonth[i] = sortedMonth[j];
              sortedMonth[j] = tempMonth;
  
              i++;
              j--;
          }
      };
  
      if(left &lt; j)
      {
          sortMonths(sortedMonth,left,j);
      }
      else if(i &lt; right)
      {
          sortMonths(sortedMonth,i,right);
      }
  
      for(int ctr = 0;ctr &lt; sortedMonth.Length; ctr++)
          Console.WriteLine(sortedMonth[ctr]);
  }
  </code></pre>
  
  <p>I've heard that one way of approaching this task is using a dictionary to point names of the months to their equivalent number values, which is what I am doing, but it still doesn't seem to work. I just want to know what I am doing wrong and what should I do to fix this. Maybe there is a better solution to this task or a better algorithm I could use? Also, I am not allowed to use predefined sorting functions and the for loop at the end is just to see if the array is sorted okay.</p>