' shell sort of an array of strings, fast version
' lngLenDic es la cantidad de palabras a ordenar (Ubound)
Sub SortArrayDic(ByRef sArray() As String, lngLenDic As Long)
Dim Value As String
Dim Index As Long
Dim index2 As Long
Dim firstEl As Long
Dim lastEl As Long
Dim distance As Long
Dim numEls As Long
If lngLenDic < 2 Then Exit Sub
firstEl = 0
lastEl = lngLenDic
numEls = lastEl - firstEl + 1
' find the best value for distance
Do
distance = distance * 3 + 1
Loop Until distance > numEls
Do
distance = distance \ 3
For Index = distance + firstEl To lastEl
Value = sArray(Index)
index2 = Index
Do While (sArray(index2 - distance) > Value)
sArray(index2) = sArray(index2 - distance)
index2 = index2 - distance
If index2 - distance < firstEl Then Exit Do
Loop
sArray(index2) = Value
Next
Loop Until distance = 1
End Sub