Integer Array Sort

  • Thread starter Thread starter Bob Palank
  • Start date Start date
B

Bob Palank

' Given

Dim v(19) As Integer ' a 20 element array

Dim vSorted(19) As Integer

Dim i As Integer

' The array v() is filled with random numbers

' It is then copied into vSorted()

then

Array.Sort(vSorted) ' is attempted but it seems to be a string sort

' and not a numeric sort.

' So in vb.net 2008, how does one code a numeric sort ?

BR

Bob
 
' Given

Dim v(19) As Integer ' a 20 element array

Dim vSorted(19) As Integer

Dim i As Integer

' The array v() is filled with random numbers

' It is then copied into vSorted()

then

Array.Sort(vSorted) ' is attempted but it seems to be a string sort

' and not a numeric sort.

' So in vb.net 2008, how does one code a numeric sort ?

BR

Bob

Can you give a small but complete code sample that demonstrates the
issue? Because, I can do:

Dim arr() As Integer = {15, 20, 100, 5, 6, 250, 0, -1}
Array.Sort(arr) ' alternatively Array.Sort(Of Integer)(arr)

And the array is sorted correctly. Do you have option strict on?
 
Back
Top