2 Questions Regarding Arrays: Declaration and Manipulation

So I’ve got some pretty basic questions regarding the use of 2D arrays in the Arduino. I did do some searching but couldn’t find the answers.

I have a pretty huge array that I’d like to squeeze on an Arduino. It is 4 rows by 720 columns. The difficulty lies primarily in the fact that the first row needs to store long variables but the other three rows only need to store byte variables. Obviously, it will save a lot of room if I can avoid the additional 6480 bytes associated with using long for the last three rows. Is there a way to construct an array where the variable type changes from row to row? And, if there is, do I have to be careful making comparisons, etc? E.g., can I still do simple things like if( *Array[1][2] > *Array[1][3]) etc?

Next question:
Is there an efficient way to swap columns? I can write some clunky memory hog function of my own to do this, but I’m sure there is a better way. Basically, I want to order the columns of the array based on the size of the long variable in the first row (row 0), i.e. something akin to (pseudo-code) :

for (i = 0; i < 720; ++i){
   for (j = 0; j < 720; ++j){
      if (*Array[0][i] > *Array[0][i+j]){SWAP COLUMNS [i] and [i+j]}
   }
}

Edit: Unless someone has a clever way of fitting this array onto a Nano or other ATMega328 based board, this will be handled by a ATmega2560 with 8 KB of SRAM

Read this before posting a programming question

Please edit your post, select the code, and put it between [code][/code] tags.

You can do that by hitting the # button above the posting area.

Thanks, Nick. I went ahead and did that although I really didn't post any code. I specifically refrained from using the code tags because it was pseudo-code/"chicken scratching" and not actual code.

although I really didn't post any code.

That's right, you didn't; C/C++ doesn't normally contain italics.

I hope I can explain this well, but if swapping columns is something you need to do a lot of, create a 720 element array of pointers to 4 element arrays. Then you just need to swap pointers instead of elements.

(You might also create a 4 element struct to efficiently store your 1 int and 3 bytes and use pointers to these structs instead of arrays. you would lose the convenience of standard array notation.)

tms8c8: I have a pretty huge array that I'd like to squeeze on an Arduino. It is 4 rows by 720 columns. The difficulty lies primarily in the fact that the first row needs to store long variables but the other three rows only need to store byte variables.

Edit: Unless someone has a clever way of fitting this array onto a Nano or other ATMega328 based board, this will be handled by a ATmega2560 with 8 KB of SRAM

1 x 720 x 4 bytes = 2880
3 x 720 x 1 byte = 2160

Total 5040 bytes

If all longs:

4 x 720 x 4 bytes = 11520 bytes

You aren't going to fit all longs anyway.

As for your original question, some sort of modified quicksort? Modified in the sense that, when you sort the first row, and have to swap, you also swap the other 3 rows to match.

AWOL:

although I really didn't post any code.

That's right, you didn't; C/C++ doesn't normally contain italics.

D'oh ... it looked fine when I hit "preview" and when I posted it; no italics ...

Thanks Keith. I'm not sure I understand how to make a 4 element structure with different variable types as you suggest. I understand the concept and think I know how to implement it if they were all ints or bytes or what-have-you. I'm just not sure how to create an object that "mixes" variable types.

And I'm sorry if I'm abusing terminology here ... I (clearly) don't have any formal education in programming. I'm just now teaching myself about pointers and the like using Google!

Thanks for the reply, Nick. I will have to search "quicksort" as I'm not familiar with it.