Am I seeing this right ?

BlitzPlus Forums/BlitzPlus Programming/Am I seeing this right ?

I made another modification to the code. I added code to check to make sure the final list is sorted. So far, I have not gotten any errors.

Dim a(1000000)

SeedRnd MilliSecs()

For i=0 To 1000000
	a(i)=Rnd(0,1000000)
Next

s=MilliSecs()
n=1000000
shellsort(n)

t=MilliSecs()
Print "time: " + Str(t-s)

GoodSort = True
For i=0 To 1000000-1
	If a(i) > a(i+1)
		GoodSort = False
		Exit
	EndIf
Next

If GoodSort Then Print "Good sort!"
If Not GoodSort Then Print "Bad sort!"

WaitKey()

Function shellsort(n)

	i=n
	
	Repeat

		;i=i/2
		;i=Int(Float(i)/1.6)
		i=Floor(Float(i)/1.6)
		
		Print Str(i)
		lowest=0
		
		For lowest=0 To i-1
		
			Repeat
				
				j=lowest
				flag=0
				
				While j+i<=n
					
					If a(j)>a(j+i) Then
						
						swap=a(j)
						a(j)=a(j+i)
						a(j+i)=swap
						flag=1
					
					EndIf
					
					j=j+i

				Wend

			Until flag=0

		Next

	Until i<=1

End Function