'------------------------------------------------------------------
'Tri QuickSort Boisgontier
'http://boisgontierj.free.fr/pages_site/tableaux.htm#Tri2DSansIndex
'Exemple: Call TriT2D(tt, 1, LBound(tt, 1), UBound(tt, 1))
'------------------------------------------------------------------
Sub TriT2D(a, ColTri, gauc, droi, Optional sens = 1) ' Quick sort
Dim ref, g, d, k, temp
ref = a((gauc + droi) \ 2, ColTri)
g = gauc: d = droi
Do
If sens > 0 Then
Do While a(g, ColTri) < ref: g = g + 1: Loop
Do While ref < a(d, ColTri): d = d - 1: Loop
Else
Do While a(g, ColTri) > ref: g = g + 1: Loop
Do While ref > a(d, ColTri): d = d - 1: Loop
End If
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 TriT2D(a, ColTri, g, droi, sens)
If gauc < d Then Call TriT2D(a, ColTri, gauc, d, sens)
End Sub