I have a list of objects that store search results for a feed search I have made. While adding to the list I give the object a score on how relevant the result is so that I can push these results to the top.
My object implements the IComparable interface and has a compareto function and all compiles correctly but when I sort the list (list.sort()) this doesn't seem to have any effect on the results (the higher scored items are not at the top of the bottom)
Can anyone advise what I am doing wrong?
Public Class SearchFeedItem
Implements IComparable
Private _score As Integer = 0
Public Property Score() As Integer
Get
Return _score
End Get
Set(ByVal value As Integer)
_score = value
End Set
End Property
Public Function CompareTo(ByVal obj As Object) As Integer Implements System.IComparable.CompareTo
Dim OtherItem As SearchFeedItem = CType(obj, SearchFeedItem)
If Me.Score < OtherItem.Score Then
Return 1
End If
If Me.Score > OtherItem.Score Then
Return -1
Else
Return 0
End If
End Function
End Class