Sub TriTableau2D_4()
T = Timer()
Dim clé() As String, index() As Long
Set Pl = [A1].CurrentRegion: Set Pl = Pl.Rows(2).Resize(Pl.Rows.Count - 1)
a = Pl.Value
Dim b()
ReDim b(LBound(a) To UBound(a), LBound(a, 2) To UBound(a, 2))
ReDim clé(1 To UBound(a, 1))
ReDim index(1 To UBound(a, 1))
For i = 1 To UBound(a)
For j = 1 To UBound(a, 2)
Select Case VarType(a(i, j))
Case Is = 5
clé(i) = clé(i) & CLng(a(i, j))
Case Is = 7
clé(i) = clé(i) & Format(a(i, j), "00000")
Case Else
clé(i) = clé(i) & a(i, j)
End Select
Next j
index(i) = i
Next i
Call Tri(clé(), index(), 1, UBound(clé))
For lig = 1 To UBound(clé)
For col = 1 To UBound(a, 2): b(lig, col) = a(index(lig), col): Next col
Next lig
[J2].Resize(UBound(b), UBound(b, 2)) = b
MsgBox Timer() - T
End Sub
Sub Tri(clé() As String, index() As Long, gauc, droi) ' Quick sort
ref = clé((gauc + droi) \ 2)
g = gauc: d = droi
Do
Do While clé(g) < ref: g = g + 1: Loop
Do While ref < clé(d): d = d - 1: Loop
If g <= d Then
temp = clé(g): clé(g) = clé(d): clé(d) = temp
temp = index(g): index(g) = index(d): index(d) = temp
g = g + 1: d = d - 1
End If
Loop While g <= d
If g < droi Then Call Tri(clé, index, g, droi)
If gauc < d Then Call Tri(clé, index, gauc, d)
End Sub