I have table myImages$={"1.png","2.png","5.png","10.png","5.png","6.png","7.png","8.png","9.png","10.png"}
I try to sort it by names
Sort(myImages$)
For k = 0 To 9
NPrint(myImages$[k])
Next
And have
1,10,2,3,4,5,6,7,8,9
How I can change sorting to have
1,2,3,4,5,6,7,8,9,10 ?
array sorting
Re: array sorting
This should do the trick if all items do start with numbers:
But that doesn't work too well if you have names starting with other than numbers too... maybe something like that for that kind of situation?
Or does anyone come up with a better idea? ![Smile :)](./images/smilies/icon_e_smile.gif)
Code: Select all
Sort(myImages$, Function(a, b) Return(Val(a) < Val(b)) EndFunction)
Code: Select all
Sort(myImages$, Function(a, b) If Val(a)=0 Or Val(b)=0 Then Return(a < b) Else Return(Val(a) < Val(b)) EndFunction)
![Smile :)](./images/smilies/icon_e_smile.gif)
Re: array sorting
Thank you very much! It is work!