Réponse acceptée !
Bonjour,
Inspire toi de cet exemple. J'ai considéré que la variable allo est de type générique List(Of Personne) ou personne représente une personne.
Voici la classe Personne:
Public
Class Personne
Public id AsInteger
Public nom AsString
EndClass
Voici la méthode de tri à l'aide de system.comparaison:
PrivateFunction SortListProc(ByVal x As Personne, ByVal y As Personne) AsInteger
If x IsNothingThen
If y IsNothingThen
Return 0
Else
Return -1
EndIf
Else
If y IsNothingThen
Return 1
Else
Dim retval AsInteger = x.id.CompareTo(y.id)
If retval <> 0 Then
Return retval
Else
Return x.id.CompareTo(y.id)
EndIf
EndIf
EndIf
EndFunction
Pour trier ta liste allo rien de plus simple:
dim allo as new system.collections.generics.List(of Personne)
'ici tu remplis allo....
dim p1 as new personne
p1.id=7
p1.name="mike"
allo.add(p1)........
'Puis tu tris:
allo.Sort(addressOf SortListProc)
Voila ++