unable to convert int array to int array..
BlitzMax Forums/BlitzMax Programming/unable to convert int array to int array..| 
 | ||
| I'm guessing its something really simple, but I just can't find it. I got the bubblesort code from wikipedia, and I don't even know if I converted the pseudocode correctly.. This gives me an error, Unable to convert Int Array to Int Array 
Local arr2:Int[11,44,55,33]
Local i
For i = EachIn arr2.Dimensions()
	Print i
Next
BubbleSort arr2
For i = EachIn arr2.Dimensions()
	Print i
Next
Function BubbleSort(A[])
 Local swapped:Int = True, i:Int, j:Int
  While swapped
     swapped = False
	    For i = 0 To A.length - 2
	
	      If A[i] > A[i + 1] Then
			j = A[i]
	        A[i] = A[i + 1]
			A[i + 1] = j
	        swapped = True
	
	      End If
	
	    Next
  Wend
End Function
I need to sort numbers in an array (or list), for comparing x and y locations, and they have to be in ascending order(1,2,4,66,86,102,3331 etc etc..) | 
| 
 | ||
| 
Local arr2:Int[] = [11,44,55,33]
Local i
For i = EachIn arr2
	Print i
Next
BubbleSort arr2
For i = EachIn arr2
	Print i
Next
Function BubbleSort(A:Int[])
 Local swapped:Int = True, i:Int, j:Int
  While swapped
     swapped = False
	    For i = 0 To A.length - 2
	
	      If A[i] > A[i + 1] Then
			j = A[i]
	        A[i] = A[i + 1]
			A[i + 1] = j
	        swapped = True
	
	      End If
	
	    Next
  Wend
End Function
First you define an array with 4 Dimensions instead of one with 1 dimension. Second you try to iterate through these dimensions, but this function (Dimonsions()) only return the Dimensions of the array, not the values in it. | 
| 
 | ||
| oops.. thanks alot :) | 
| 
 | ||
| Can't you just use Arr2.Sort()? Never tried the Sort method before, but it should work, no? Russell |