Morgoth
03-11-2005, 01:28 AM
This is how I swap integers in an array:
For I = 0 To 6
For J = 0 To I
If intCardCount(I) > intCardCount(J) Then
intTemp = intCardCount(J)
intCardCount(J) = intCardCount(I)
intCardCount(I) = intTemp
End If
Next J
Next I
I can use a mathematical method and not have to use a 3rd variable, but this is easier to read.
Now, I want to swap integers in a 2 dimensional array.
I want to to swap the location of the second dimention of the array. The first dimention is the location ID. I want the seond array dimention of the array to stay in perfect order.
I am going to test a few ideas out on my own, but if there is a proper method for this, I'd like to know please.
Edit: This is an example of what I need. And don't worry about the condition of why it changes, I just need to know how to swap them:
(1,1) = "a" (1,2) = "b" (1,3) = "c"
(2,1) = "d" (2,2) = "e" (2,3) = "f"
(3,1) = "g" (3,2) = "h" (3,3) = "i"
swap first and second
(1,1) = "s" (1,2) = "e" (1,3) = "f"
(2,1) = "a" (2,2) = "b" (2,3) = "c"
(3,1) = "g" (3,2) = "h" (3,3) = "i"
For I = 0 To 6
For J = 0 To I
If intCardCount(I) > intCardCount(J) Then
intTemp = intCardCount(J)
intCardCount(J) = intCardCount(I)
intCardCount(I) = intTemp
End If
Next J
Next I
I can use a mathematical method and not have to use a 3rd variable, but this is easier to read.
Now, I want to swap integers in a 2 dimensional array.
I want to to swap the location of the second dimention of the array. The first dimention is the location ID. I want the seond array dimention of the array to stay in perfect order.
I am going to test a few ideas out on my own, but if there is a proper method for this, I'd like to know please.
Edit: This is an example of what I need. And don't worry about the condition of why it changes, I just need to know how to swap them:
(1,1) = "a" (1,2) = "b" (1,3) = "c"
(2,1) = "d" (2,2) = "e" (2,3) = "f"
(3,1) = "g" (3,2) = "h" (3,3) = "i"
swap first and second
(1,1) = "s" (1,2) = "e" (1,3) = "f"
(2,1) = "a" (2,2) = "b" (2,3) = "c"
(3,1) = "g" (3,2) = "h" (3,3) = "i"