Currently I have an object implementing the IComparable interface (ASP.NET 3.5, VB). When I place several instantiated objects into a Generics list, I sort them by doing a simple someList.Sort
. My CompareTo()
function is this:
Public Function CompareTo(ByVal obj As Object) As Integer Implements
System.IComparable.CompareTo
'default is number of votes (opposite direction, highest first)'
Dim sent As Sentence = CType(obj, Sentence)
Return Not Points.CompareTo(sent.Points)
End Function
This works fine, except now I need to sort by another property, the DateSubmitted property, as a subset of the Points. For example, if three sentences have votes: 3, 1, 1, I want the one with the highest votes first (obviously) and of the two sentences with one vote, the one submitted the earliest to be listed.
Is this possible with CompareTo(), or should I just hit the database again and sort it there?
Thanks