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.ICompara ble(Of clsPerson).Comp areTo
If Me.Language = myPerson.Langua ge Then
If Me.City = myPerson.City Then
Return Me.Name.Compare To(myPerson.Nam e)
Else
Return Me.City.Compare To(myPerson.Cit y)
End If
Else
Return Me.Language.Com pareTo(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.ICompara ble(Of clsPerson).Comp areTo
If Me.Language = myPerson.Langua ge Then
If Me.City = myPerson.City Then
Return Me.Name.Compare To(myPerson.Nam e)
Else
Return Me.City.Compare To(myPerson.Cit y)
End If
Else
Return Me.Language.Com pareTo(myPerson .Language)
End If
End Function
Comment