dragonwell
Programmer
I have a class that needs to implement IComparable. I want to do a multi-field sort, such as a SQL "order by" clause (select * from person order by name, age). So say my class Person has a Name string and an Age int, what would the CompareTo method look like?
[blue]_______________________________________[/blue]
Business Logic:"AND when tweetle beetles battle with paddles in a puddle, they call it a tweetle beetle puddle paddle battle AND..." - Dr. Suess
Code:
Public Function CompareTo(ByVal other As Person) As Integer Implements System.IComparable(Of Person).CompareTo
'sort by name... ok
Return other.Name.CompareTo(Me.Name)
'sort by age... ok
Return other.Age.CompareTo(Me.Age)
'how to do both???
End Function
[blue]_______________________________________[/blue]
Business Logic:"AND when tweetle beetles battle with paddles in a puddle, they call it a tweetle beetle puddle paddle battle AND..." - Dr. Suess