Private cls_TabOrigine() As Variant ' Ici je conserve la structure du tableau d'origine
' Element de travail ci-dessous !
Private cls_Tabtemp() As Variant ' Ici j'effectu les modification de structure du tableau de tri
Private cls_NumCol1 As Integer ' Avec le numéro de colonne a trié !
Property Let ajout(ByRef Tableau() As Variant, ByVal NumCol1 As Integer)
cls_Tabtemp = Tableau ' Le tableau 2 dimension dans le module de classe
cls_NumCol1 = NumCol1 ' Le choix de la colonne de tri
' Option Je conserve la structure d'origine du tableau initial non modifié !
cls_TabOrigine = Tableau
End Property
Property Get RecupTabOrigine() As Variant()
RecupTabOrigine = cls_TabOrigine
End Property
Property Get triCroissant() As Variant()
' Tri la variable tableau
Croissant cls_Tabtemp, cls_NumCol1, LBound(cls_Tabtemp, 1), UBound(cls_Tabtemp, 1)
' Renvois le Resultat dans le Module Standard
triCroissant = cls_Tabtemp
End Property
Property Get triDeCroissant() As Variant()
' Tri la variable tableau
DeCroissant cls_Tabtemp, cls_NumCol1, LBound(cls_Tabtemp, 1), UBound(cls_Tabtemp, 1)
' Renvois le Resultat dans le Module Standard
triDeCroissant = cls_Tabtemp
End Property
Property Get ContenuVarTab(ByRef Tabtemp() As Variant, ByRef i As Long, ByRef j As Long)
ContenuVarTab = Tabtemp(i, j)
End Property
Private Sub Croissant(a() As Variant, colTri, gauc, droi)
' Tri "Croissant" d'un tableau (Array) à 2 dimensions
ref = a((gauc + droi) \ 2, colTri)
g = gauc: d = droi
Do
' Pour un tri Croissant
Do While a(g, colTri) < ref: g = g + 1: Loop
Do While ref < a(d, colTri): d = d - 1: Loop
If g <= d Then
For k = LBound(a, 2) To UBound(a, 2)
temp = a(g, k): a(g, k) = a(d, k): a(d, k) = temp
Next k
g = g + 1: d = d - 1
End If
Loop While g <= d
If g < droi Then Call Croissant(a, colTri, g, droi)
If gauc < d Then Call Croissant(a, colTri, gauc, d)
End Sub
Private Sub DeCroissant(a() As Variant, colTri, gauc, droi)
' Tri "DéCroissant" d'un tableau (Array) à 2 dimensions
ref = a((gauc + droi) \ 2, colTri)
g = gauc: d = droi
Do
' Pour un tri DéCroissant
Do While a(g, colTri) > ref: g = g + 1: Loop
Do While ref > a(d, colTri): d = d - 1: Loop
If g <= d Then
For k = LBound(a, 2) To UBound(a, 2)
temp = a(g, k): a(g, k) = a(d, k): a(d, k) = temp
Next k
g = g + 1: d = d - 1
End If
Loop While g <= d
If g < droi Then Call DeCroissant(a, colTri, g, droi)
If gauc < d Then Call DeCroissant(a, colTri, gauc, d)
End Sub