Implementing IComparable

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Does anyone know if it's possible, and if so, how to implement a secondary comparison criteria

Let's say we've got a collection of Person objects that we want sorted by LastName then by FirstName..
How would I construct a CompareTo function to accomplish this

Thanks in advance!
 
* "=?Utf-8?B?YXJ0aWZhY3Q=?= said:
Does anyone know if it's possible, and if so, how to implement a secondary comparison criteria?

Let's say we've got a collection of Person objects that we want sorted by LastName then by FirstName...
How would I construct a CompareTo function to accomplish this?

\\\
Dim Result As Integer = x.LastName.CompareTo(y.LastName)
If Result = 0 Then
Result = x.FirstName.CompareTo(y.FirstName)
End If
Return Result
///
 
Back
Top