[futurebasic] Sorting problem

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 1999 : Group Archive : Group : All Groups

From: Mark Arnold <mda515t@...>
Date: Thu, 11 Nov 1999 14:50:05 -0600
I've been beating my head on this all day and I'm beginning to feel really
stupid. I just need to do a simple sort on an array. I've tried several
different things and nothing seems to work. Following is an example. (It
runs as is in FB^3). Can someone find what I've done wrong. Thanks.

-mark-


dim sub,swaps,chk,n,item,x
dim menuArray$(10)


item=6

menuArray$(0)="dog"
menuArray$(1)="cat"
menuArray$(2)="horse"
menuArray$(3)="pig"
menuArray$(4)="aardvark"
menuArray$(5)="giraffe"

'print as is first
for x=0 to item-1
print menuArray$(x)
next
print

n=item
sub=0
swaps=_true
while swaps
swaps=_false
for chk=n-1 to sub step -1
long if menuArray$(chk)>menuArray$(chk+1)
swap menuArray$(chk),menuArray$(chk+1)
swaps=_true
end if
next chk
sub=sub+1
wend

'now print the (supposedly) sorted list
for x=0 to item-1
print str$(x);menuArray$(x)
next