http://www.purebasic.fr/english/viewtop ... 13&t=57817
...I came up with this procedure.
It sorts a string array by its numerical leading value,
instead of by its alphabetical leading value. It's okay
for small arrays, but horribly slow on large ones.

Team: A native flag to do this for SortArray() would be
really nice, such as #PB_Sort_Numeric. For the future?
Code: Select all
Procedure SortStringArrayByValue(Array tmp$(1))
Repeat
swapped=0
For i=0 To ArraySize(tmp$())-1
If Val(tmp$(i+1))<Val(tmp$(i))
Swap tmp$(i+1),tmp$(i)
swapped=1
Break
EndIf
Next
Until swapped=0
EndProcedure
Dim a$(3)
a$(0) = "100,test1.txt"
a$(1) = "10 test2.txt"
a$(2) = "200test3.txt"
a$(3) = "20 test4.txt"
SortStringArrayByValue(a$())
For i=0 To 3
Debug a$(i)
Next