Sub test()
Dim Liste As Variant
Liste = Array("jaune", "vert", "orange", "blanc", "rouge", "noir", "fuchsia", "marron")
tri Liste, LBound(Liste), UBound(Liste), 0
MsgBox Join(Liste, vbLf)
End Sub
Sub testy2()
Dim Liste(0 To 999999), i&, t(0 To 999999, 1 To 1)
Randomize
For i = 0 To 999999: Liste(i) = Int(Rnd * 75000): t(i, 1) = Liste(i): Next
MsgBox "départ"
tim = Timer
tri Liste, LBound(Liste), UBound(Liste), 0
MsgBox Format(Timer - tim, "#0.000 /sec") & " pour le tri " & Join(Liste, ",")
End Sub
'
Sub tri(a As Variant, gauc, droi, optional sens As Long=0) ' Quick sort
ref = a((gauc + droi) \ 2)
g = gauc: d = droi
Do
'choix du sens
Select Case sens
Case 0
' Pour un tri croissant
Do While a(g) < ref: g = g + 1: Loop
Do While ref < a(d): d = d - 1: Loop
Case 1
' Pour un tri décroissant
Do While a(g) > ref: g = g + 1: Loop
Do While ref > a(d): d = d - 1: Loop
End Select
If g <= d Then
temp = a(g): a(g) = a(d): a(d) = temp
g = g + 1: d = d - 1
End If
Loop While g <= d
If g < droi Then Call tri(a, g, droi, sens)
If gauc < d Then Call tri(a, gauc, d, sens)
End Sub