Function StringSort(chain)
Dim T, i&, a&, q&, z&, mem, B&
T = Split(chain, " ")
'premier tri par la longueur de chaine
ReDim tx(UBound(T))
B = 1
For i = LBound(T) To UBound(T)
If Len(T(i)) = 1 Then q = q + 1: a = a + 1: tx(a - 1) = T(i) Else B = B - 1: tx(UBound(T) + B) = T(i)
Next
q = q - 1
'2d tri uniquement les chaines de 1 caractères(tri en insertion on insert un item de plus a chaque tour de boucle 1
For i = LBound(tx) + 1 To q - 1
For z = LBound(tx) To i
If tx(i) > tx(z) Then mem = tx(i): tx(i) = tx(z): tx(z) = mem
Next
Next
'3eme tri les chaines de deux caractères(idem tri à insertion)
For i = q + 2 To UBound(tx) - 1
For z = q + 1 + 1 To i
If tx(i) > tx(z) Then mem = tx(i): tx(i) = tx(z): tx(z) = mem
Next
Next
StringSort = Join(tx, " ")
End Function