Ha! Join is better than how rebuilt the string list, however, it still produces the same result.
"1,5,8,99,4,2,0,35,21,17,42"
becomes
"0,1,17,2,21,35,4,42,5,8,9"
when it should be
"0,1,2,4,5,8,9,17,21,35,42"
Looking for a resolution now. If I find one sooner than someone else, I'll post for you.
Option Explicit
Sub CallIt()
Dim StringToSort As String
StringToSort = "1,5,8,99,4,2,0,35,21,17,42"
MsgBox StringToSort
BubbleSrt StringToSort, True
MsgBox StringToSort
Debug.Print StringToSort
StringToSort = "1,5,8,99,4,2,0,35,21,17,42"
MsgBox StringToSort
BubbleSrt StringToSort, False
MsgBox StringToSort
Debug.Print StringToSort
End Sub
Public Function BubbleSrt(StringIO As String, Ascending As Boolean)
Dim ArrayTmp As Variant
Dim ArrayIn() As Variant
Dim SrtTemp As Variant
Dim i As Long
Dim j As Long
ArrayTmp = Split(StringIO, ",")
ReDim ArrayIn(LBound(ArrayTmp) To UBound(ArrayTmp))
For i = LBound(ArrayTmp) To UBound(ArrayTmp)
ArrayIn(i) = CDbl(ArrayTmp(i))
Next
If Ascending = True Then
For i = LBound(ArrayIn) To UBound(ArrayIn)
For j = i + 1 To UBound(ArrayIn)
If ArrayIn(i) > ArrayIn(j) Then
SrtTemp = ArrayIn(j)
ArrayIn(j) = ArrayIn(i)
ArrayIn(i) = SrtTemp
End If
Next j
Next i
Else
For i = LBound(ArrayIn) To UBound(ArrayIn)
For j = i + 1 To UBound(ArrayIn)
If ArrayIn(i) < ArrayIn(j) Then
SrtTemp = ArrayIn(j)
ArrayIn(j) = ArrayIn(i)
ArrayIn(i) = SrtTemp
End If
Next j
Next i
End If
StringIO = Join(ArrayIn, ",")
End Function