Вот пример, который я скопировал из недавнего проекта. Работает как шарм. Просто не забудьте вызвать SORT с соответствующей функцией. Это выходит за рамки интерфейса IComparable, поэтому вы можете удалить его из объявления класса.
Public Class Purchaser
....
Public Shared Function CompareByGroup( _
ByVal x As Purchaser, ByVal y As Purchaser) As Integer
If x Is Nothing Then
If y Is Nothing Then
' If x is Nothing and y is Nothing, they're equal.
Return 0
Else
' If x is Nothing and y is not Nothing, y is greater.
Return -1
End If
Else
If y Is Nothing Then
' If x is not Nothing and y is Nothing, x is greater.
Return 1
Else
' ...and y is not Nothing, compare by GroupName.
Return x.GroupName.CompareTo(y.GroupName)
End If
End If
End Function
Public Shared Function CompareByName( _
ByVal x As Purchaser, ByVal y As Purchaser) As Integer
... 'you get the idea
End Function
И назовите их вот так ...
tempList.Sort(AddressOf Classes.Purchaser.CompareByGroup)
или
tempList.Sort(AddressOf Classes.Purchaser.CompareByName)