J
John Devlon
Hi everyone,
With this post I would like to ask you all a small question.
I'm trying to sort an array of objects using IComparable. Adding below
displayed code to a class and triggering the sort function works fine. Thats
not the problem.
The only thing I would like to change is: I would like sort the Name
descending (starting with the z)...
Does anyone know how ?
Many Thanx
John
Ps: using VB.NET 2005
Code:
Public Function CompareTo(ByVal myPerson As clsPerson) As Integer Implements
System.IComparable(Of clsPerson).CompareTo
If Me.Language = myPerson.Language Then
If Me.City = myPerson.City Then
Return Me.Name.CompareTo(myPerson.Name)
Else
Return Me.City.CompareTo(myPerson.City)
End If
Else
Return Me.Language.CompareTo(myPerson.Language)
End If
End Function
With this post I would like to ask you all a small question.
I'm trying to sort an array of objects using IComparable. Adding below
displayed code to a class and triggering the sort function works fine. Thats
not the problem.
The only thing I would like to change is: I would like sort the Name
descending (starting with the z)...
Does anyone know how ?
Many Thanx
John
Ps: using VB.NET 2005
Code:
Public Function CompareTo(ByVal myPerson As clsPerson) As Integer Implements
System.IComparable(Of clsPerson).CompareTo
If Me.Language = myPerson.Language Then
If Me.City = myPerson.City Then
Return Me.Name.CompareTo(myPerson.Name)
Else
Return Me.City.CompareTo(myPerson.City)
End If
Else
Return Me.Language.CompareTo(myPerson.Language)
End If
End Function