I have spent hours of trying to sort this out (I am sure I am not looking in the right place).
I have a TextField into which a user can type only Integers (I have that covered) separated by a space. Here is a possible input: “1 2 3 4 5 6 10 25 3 2” - this is the result: “1 10 2 2 25 3 3 4 5 6”.
How can I get the 10 and 25 (and probably 100 and 299) into the correct order? I want to use these integers further in the program, but I think it would look better (more professional) if they were in proper numerical order. I notice the same thing happens on Windows.
Also keep SortWith in mind. You can “sort” an array into any arbitrary order by creating a second, “index” array, filling it with values that determine order, then sorting it along with your original array. In your case, if you wanted to keep the original array as strings instead of converting them to integers, you’d do this:
dim IntArr() as Integer
redim IntArr( StrArr.Ubound )
for i as Integer = 0 to StrArr.Ubound
IntArr( i ) = Val( StrArr( i ) )
next i
IntArr.SortWith( StrArr )
// Now StrArr is in numerical order instead of "alphabetical" order