title: C# order column by date - header column datetime
body: <p>we try to sort the column of my datagridview in C# from the most recent to the other, but i didn't find a solution.</p>
  
  <p>Below the image of my little program 
  <a href="https://i.stack.imgur.com/pIFBO.png" rel="nofollow noreferrer">references</a></p>
  
  <p>my last test it's to use:</p>
  
  <pre><code>      for (int i=1; i&lt;dsForecast.Columns.Count; i++)
          {
              DataColumn col = dsForecast.Columns[i];
              dtListDate.Add(DateTime.Parse(col.ColumnName));
          }
  
          Dictionary&lt;DateTime, int&gt; dList = new Dictionary&lt;DateTime, int&gt;();
          for (int i = 0; i &lt; dtListDate.Count; i++)
              dList.Add(dtListDate[i], i);
  
          dtListDate.Sort((a, b) =&gt; a.CompareTo(b));
  
  
          foreach (DataColumn c in dsForecast.Columns)
              this.dgwForecast.Columns[c.ColumnName].DisplayIndex = dsForecast.Columns.IndexOf(c);
  </code></pre>
  
  <p>Can anyone help  me to find a solution for this?</p>
  
  <p>i want a result like this,<a href="https://i.stack.imgur.com/KsnRX.png" rel="nofollow noreferrer">result</a></p>
  
  <p>I undestrand that the solution is to move the columnn with its contents, but how?</p>
  
  <p>Can someone Help me?</p>