title: DatagridView Column Sorting
body: <p>I have bind datagrid with following values.
  Id as Int,Price as int, IsActive as bit.
  Now I want to sort data based on IsActive when i click on column header of IsActive.</p>
  
  <p>I did the same thing for Id and it working properly  but for IsActive it is not working.</p>
  
  <p>Below is my code for IsActive field :</p>
  
  <pre><code> private void dataGridView1_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
      {
          // Try to sort based on the cells in the current column.
          e.SortResult = System.String.Compare(e.CellValue1.ToString(), e.CellValue2.ToString());
  
          // If the cells are equal, sort based on the ID column. 
          if (e.SortResult == 0 &amp;&amp; e.Column.Name != "IsActive ")
          {
              e.SortResult = System.String.Compare(
                  dataGridView1.Rows[e.RowIndex1].Cells["IsActive "].Value.ToString(),
                  dataGridView1.Rows[e.RowIndex2].Cells["IsActive "].Value.ToString());
          }
          e.Handled = true;
      }
  </code></pre>
  
  <p>I want to know How can i sort Boolean data in datagridView.</p>