I have a ListView setup with two groups and three columns, one of the groups has 3 ListViewItems under it. I'm sure the items would be in a different order depending on which column you sort on. I implemented a custom class for sorting and wired up an event handler for capturing column clicks. Here's my code:
Code:
private void lvSyncItems_ColumnClick(object sender, ColumnClickEventArgs e)
{
	lvSyncItems.ListViewItemSorter = new ListViewSorter(e.Column);
}

private class ListViewSorter : System.Collections.IComparer
{
	private int m_ColumnIndex;

	public ListViewSorter(int columnIndex)
	{
		m_ColumnIndex = columnIndex;
	}

	#region IComparer Members

	public int Compare(object x, object y)
	{
		return String.Compare((x as ListViewItem).SubItems[m_ColumnIndex].Text, (y as ListViewItem).SubItems[m_ColumnIndex].Text);
	}

	#endregion
}
I have checked the return value from the compare method as the listview is sorting during a column click and everything is correct except the items never get reordered on screen! Does this have something to do with the fact that I'm using groups? Thanks!