Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Sub ListSort(ByRef Arr() As String, Num As Integer)
' Sorts an array of strings using the Shell Sort algorithm.
Dim gap, i, j, k As Integer
Dim tmp As String
gap = Num \ 2
Do While (gap > 0)
For i = (gap + 1) To Num
j = i - gap
Do While j > 0
k = j + gap
If Arr(j) <= Arr(k) Then
j = 0
Else
tmp = Arr(j)
Arr(j) = Arr(k)
Arr(k) = tmp
End If
j = j - gap
Loop
Next i
gap = gap \ 2
Loop
End Sub
Sub ListSort(ByRef Arr() As String, ARows As Long, ACols As Long, SortCol As Long)
' Sorts a 2D array of strings using the Shell Sort algorithm.
Dim gap, i, j, k, n As Integer
Dim tmp As String
gap = ARows \ 2
Do While (gap > 0)
For i = (gap + 1) To ARows
j = i - gap
Do While j > 0
k = j + gap
If Arr(j, SortCol) <= Arr(k, SortCol) Then
j = 0
Else
For n = 1 To ACols
tmp = Arr(j, n)
Arr(j, n) = Arr(k, n)
Arr(k, n) = tmp
Next n
End If
j = j - gap
Loop
Next i
gap = gap \ 2
Loop
End Sub