Sorting procedure (OWBasic-Coding Forum)
Hello everyone, I know this may sound stupid, but I'm trying to do a sorting procedure in OWBasic and I'm not able to do it work right. I want a sort this kind of data:
const data$=("Test-02","Test","Test-01","Test-03","TestA")
And sort it in ascending order by placing the entries without numbers at first place, like this:
Test
TestA
Test-01
Test-02
Test-03
I have no problem in what order the entries without numbers are placed, I just would like some help because indeed I have trouble doing it.
Here's the code I have made up to now (it also is a sorting procedure in descending order, so perhaps that's what's affecting the other one).
dir=0
dim comp[9],result$[10]
const data$=("Test-03","Test","Test-02","Test-01","Test-05","Test-04","Simple")
p=-1
case select dir
case 0
oc=-1
p=-1:i=-1
do
inc p:inc i
comp[i]=p
loop until p=9
case 1
oc=-1
p=10:i=-1
do
dec p:inc i
comp[i]=p
loop until p=0
endcase
k=-1
for n=0 to 9
for i=0 to arraysize(data)
a=pos(string(comp[n]),data[i])
b=pos("-",data[i])
if a<0 and b<0 then
for tmp=0 to arraysize(result)
if result$[tmp]=data[i] goto 1
next
case select dir
case 0
tt=k
do
result[tt+1]=result[tt]
dec tt
loop while tt>0
result$[k]=data[i]
goto 1
case 1
result$[arraysize(data)+oc]=data[i]
inc oc
goto 1
endcase
endif
if a>-1 then
if int(data[i]{a})<=comp[n] then
inc k
if k>arraysize(data) goto 1
for tmp=0 to arraysize(result)
if result$[tmp]=data[i] goto 1
next
result$[k]=data[i]
break
endif
endif
1
next
next
for i=0 to 5
? data[i]
next
?
for i=0 to 7
? result$[i]
next
Thanks in advance
gesamter Thread:

Mix-Ansicht




