title: assigning comparer to ListViewItemSorter
body: <p>I want to sort a ListView control in C# based on columns. I have created ColumnClickEventHandler:</p>
  
  <pre><code>    private void contactsListView_ColumnClick(object sender, ColumnClickEventArgs e)
      {
          contactsListView.ListViewItemSorter = new ListViewItemComparer(e.Column);
          contactsListView.Sort();
      }
  </code></pre>
  
  <p>Where ListViewItemComparer class looks like this:</p>
  
  <pre><code>   class ListViewItemComparer : IComparer&lt;ListViewItem&gt;
  {
      private int col;
      public ListViewItemComparer()
      {
          col = 0;
      }
      public ListViewItemComparer(int column)
      {
          col = column;
      }
      public int Compare(ListViewItem x, ListViewItem y)
      {
          int returnVal = -1;
          returnVal = String.Compare(x.SubItems[col].Text, y.SubItems[col].Text);
          return returnVal;
      }
  }
  </code></pre>
  
  <p>This code won't compile cause contactsListView.ListViewItemSorter is type IComparer and class ListViewItemComparer is IComparer.</p>
  
  <p>Is there a way to explicitly cast one to the other? Or just do sorting another way?</p>
  
  <p>Thanks in advance</p>