Hey guys,
How would I go about sorting an Array of Strings, using either a selection sort or a insertion sort?
I have written an insertion sort, but i only works for integers. How can i modify it to work with strings.
Public Sub InsertionSort(ByVal numitems As Integer)
Dim currentitem, currentdataitem, comparison, shuffleitem As Integer
Dim finish As Boolean
currentitem = 1
While currentitem <= (numitems - 1)
currentdataitem = item(currentitem)
comparison = 0
finish = False
While comparison < currentitem And finish = False
If currentdataitem < item(comparison) Then
shuffleitem = currentitem
While shuffleitem > comparison
item(shuffleitem) = item(shuffleitem - 1)
shuffleitem = shuffleitem - 1
Wend
item(comparison) = currentdataitem
finish = True
End If
comparison = comparison + 1
Wend
currentitem = currentitem + 1
Wend
End Sub
Any help is appreciated.
Thanks,
Jem00