public int Compare(object x, object y)
{
ListViewItem itemX = x as ListViewItem;
ListViewItem itemY = y as ListViewItem;
// First two columns - numbers
if (col == 0 || col == 1)
{
try
{
return Int32.Parse(itemX.SubItems[col].Text) -
Int32.Parse(itemY.SubItems[col].Text);
}
catch (Exception)
{ }
}
return String.Compare(itemX.SubItems[col].Text,
itemY.SubItems[col].Text);
}