public int Compare(object x, object y)
{
var Lx = x as ListViewItem;
var Ly = y as ListViewItem;
var Mx = Lx.Tag as Mod;
var My = Ly.Tag as Mod;
if (x == y)
return 0;
if (x == null || Mx == null)
return 1;
if (y == null || My == null)
return -1;
switch (mode)
{
case 0: //Text sorting
default:
return string.Compare(Lx.Text, Ly.Text);
case 1: //Install date sorting
if (Lx.Tag == null || !My.Installed)
return -1;
if (Ly.Tag == null || !Mx.Installed)
return 1;
return (int)(My.InstallTime - Mx.InstallTime).TotalSeconds;
}
}
}