;PB 4.41-Bug
RandomSeed( ElapsedMilliseconds() )
#ITEMS=6
;Fill Array With Random Values:
Dim idx.i(#ITEMS)
For i = 1 To #ITEMS
idx(i-1) = i*10; Random(10000)
Next
Debug "Before Sorting:"
Debug "---------------"
;Print Result
For i = 0 To #ITEMS-1
Debug( Str( idx(i) ) )
Next
;Sort
SortArray(idx(),#PB_Sort_Ascending)
Debug "After Sorting:"
Debug "---------------"
;Print Result
For i = 0 To #ITEMS-1
Debug( Str( idx(i) ) )
Next
;With Sort we loose the highest number, and get a zero as lowest
;Also if ther are no zero value in the array.
Mike
Last edited by neotoma on Thu Mar 18, 2010 9:43 pm, edited 1 time in total.
...just replace "#ITEMS - 1" with "#ITEMS" in both loops. Your code seems to be attempting to avoid collecting the value of the first index (index zero). If there is a good reason to do that, then this is how:
#ITEMS=6
;Fill Array With Random Values:
Dim idx.i(#ITEMS)
For i = 1 To #ITEMS
idx(i) = i*10
Next
Debug "Before Sorting:"
Debug "---------------"
;Print Result
For i = 1 To #ITEMS
Debug( Str( idx(i) ) )
Next
;Sort
SortArray(idx(),#PB_Sort_Ascending)
Debug "After Sorting:"
Debug "---------------"
;Print Result
For i = 1 To #ITEMS
Debug( Str( idx(i) ) )
Next
IdeasVacuum
If it sounds simple, you have not grasped the complexity.