If you want to sort the arraylist, you still need to write a class that inherits from icomparer. No other method can be used. It seems that I have to write it. Haha.
Public class normaldepartmentuserobjectcollection: system. Collections. arraylist
{
Bool CVT = true;
Public normaldepartmentuserobjectcollection ()
{
}
Public normaldepartmentuserobjectcollection (system. Collections. arraylist C)
{
}
Public override void sort ()
{
CVT =! CVT;
Sort (New sorter (CVT ));
}
Class sorter: system. Collections. icomparer
{
Bool convert = false;
Internal sorter (bool CVT)
{
Convert = CVT;
}
# Region icomparer Member
Public int compare (Object X, object y)
{< br> If (convert)
return string. compare (normaldepartmentuserobject) Y ). name, (normaldepartmentuserobject) X ). name);
else
return string. compare (normaldepartmentuserobject) X ). name, (normaldepartmentuserobject) Y ). name);
}
# Endregion
}
}
It's easy to implement a compare method. Because we compare the name attribute of a custom class, we use the string compare method.