I'm having some trouble correctly sorting an array numerically based on strings that contain numbers:
So, the sort works for all strings up until I get into 2 digit numbers.
For example, if the array contains "Issue 2:" "Issue 5:" and "Issue 3:" it correctly sorts the strings to be 2, 3, 5.
Unfortunately, as soon as I get two digit numbers it no longer sorts correctly. So "Issue 10:" "Issue 8:" and "Issue 13:" will not sort.
I'm fairly certain it has to do with the fact that I'm trying to sort based on strings than on numeric values. Is there a way to have it correctly sort via strings? Or is there an "easy" way to change the string numbers into actual numerical values.
'This creates a list of what we want to sort by.
'The string format will always be "Issue 1:" "Issue 3:" "Issue 2:" "Issue 11:"
'Issue x:" etc.
IssueListActual = CreateIssueListFromSection(sectionFind)
'This creates a duplicate array to be sorted
IssueListSorted = IssueListActual
'Sorts the array as seen in below subroutine
BubbleSort IssueListSorted
Sub BubbleSort(arr)
Dim strTemp As String
Dim i As Long
Dim j As Long
Dim lngMin As Long
Dim lngMax As Long
lngMin = LBound(arr)
lngMax = UBound(arr)
For i = lngMin To lngMax - 1
For j = i + 1 To lngMax
If arr(i) > arr(j) Then
strTemp = arr(i)
arr(i) = arr(j)
arr(j) = strTemp
End If
Next j
Next i
End Sub