title: Sorting a datagrid columns, I have the code and it sort of works
body: <p>I'm trying to sort the columns of a datagrid A to Z, the code below works apart from I get a column beginning with 'c' in between the 'A' (e.g. a,a,a,a,c,a,a,b,b,b), this happens the first time I run the code. If I then use columnNames.Reverse(); (Z to A) and then re-run columnNames.Sort() (A to Z) it sorts correctly. Why would this be?</p>
  
  <pre><code> List&lt;string&gt; columnNames = new List&lt;string&gt;();
   foreach (DataGridViewColumn col in dataGridView1.Columns)
   columnNames.Add(col.HeaderText);
   columnNames.Sort();
   foreach (DataGridViewColumn col in dataGridView1.Columns)
       col.DisplayIndex = columnNames.IndexOf(col.HeaderText);
  </code></pre>
  
  <p>Thanks</p>