As described below:
INTERNAL CLASS LISTVIEWITEMCOMPARER: IComparer
{
Private int co1;
Private sortorder order;
Public ListViewItemComparer ()
{
COL = 0;
ORDER = Sortorder.ascending;
}
Public ListViewItemComparer (int Column, Sortorder Order)
{
COL = column;
THIS.Order = ORDER;
}
Public Int Compare (Object X, Object Y)
{
Int retURNVAL = -1;
IF ((ListViewItem) x). Subitems.count> Col && ((listviewItem) Y) .SUBITEMS.COUNT> COL)
{
Returnval = string.Compare ((ListViewItem) x) .subitems [col] .text,
(ListViewItem) Y) .SUBITEMS [col] .text);
IF (ORDER == Sortorder.Descending)
ReturnVal * = -1;
}
Return ReturnVal;
}
}
Call: The first parameter is the sort field, the second parameter is sorted mode (ascending, descending)
This.getCurrentlist (). ListviewItemsORTER = New ListViewItemComparer (2, this.getcurrentlist (). sorting);
THIS.GETCURRENTLIST (). sort ();