Sorting numbers that are in strings?

I have some strings that need to be sorted.
DIm lst() As String = Array(“12”, “9”, “09”, “10”)

So If i sort this with sortthis. Then the sort order is incorrect.
How do i does the that? :slight_smile:

Make a second array, for each entry add the value of the entry to the second array, then sort the first array with the second using SortWith.

You could also look at$Sort where you use a delegate method to “help” the sort mechanism.

I’m getting the delegate idea.
What I’m not getting is how does the sortwith method take advantage of the delegate?
I’ll try Markus’s suggestion.

Delegate would be something like

[code]Function NumStringCompare(value1 As string, value2 As string) As Integer
’ return a positive value if it considers value1 to be greater than value2
’ zero if it considers value1 and value2 to be equal
’ and a negative value if it considers value1 to be less than value2

dim ret as integer '0 by default

If  val(value1) > val(value2)  Then ret=1
If  val(value1) < val(value2)  Then ret=-1
Return ret

End Function

lst.Sort(AddressOf NumStringCompare)[/code]