I've got a bit of a mess here that I'm trying to clean up. I have a variable with numbers put in to in a random order, separated by a space:
numstring = "23 5 187 13"
I want to sort it, so I am using this:
bits = Split(numstring, " ")
for a = UBound(bits) - 1 To 0 Step -1
for j=0 to a
if bits(j)>bits(j+1) then
temp=bits(j+1)
bits(j+1)=bits(j)
bits(j)=temp
end if
next
next
The PROBLEM I have is that this isn't sorting it numerically, it looks like it is sorting it alphabetically. That means that the end result is this:
5 23 187 13
Is there any way I can do this?
numstring = "23 5 187 13"
I want to sort it, so I am using this:
bits = Split(numstring, " ")
for a = UBound(bits) - 1 To 0 Step -1
for j=0 to a
if bits(j)>bits(j+1) then
temp=bits(j+1)
bits(j+1)=bits(j)
bits(j)=temp
end if
next
next
The PROBLEM I have is that this isn't sorting it numerically, it looks like it is sorting it alphabetically. That means that the end result is this:
5 23 187 13
Is there any way I can do this?