two questions on arrays

Results 1 to 3 of 3

Thread: two questions on arrays

  1. #1
    Join Date
    Dec 1969

    Default two questions on arrays

    first question, what&#039;s the syntax for setting a multidimensional array in one line of code?<BR><BR>like this: newarray = array("one","two","three")<BR><BR>but multidimensional<BR><BR>and then, any good advice on sorting a multi-dimensional by date?

  2. #2
    Join Date
    Dec 1969

    Default RE: two questions on arrays

    1. Dim myArray(3)(3)<BR>2. Search this site... there&#039;s a code example that does just that.

  3. #3
    Join Date
    Dec 1969

    Default DG wrong on both counts

    (1) There is NO WAY to initialize a multidimensional array, period. Other than by DIMing it and then assigning to its individual elements.<BR> Dim ar(2,3)<BR> ar(0,0) = "column 0, row 0"<BR> ar(1,0) = "column 1, row 0"<BR> ar(2,0) = "column 2, row 0"<BR> ar(0,1) = "column 0, row 1"<BR> ... etc ...<BR><BR>You *can*, however, initialize an *ARRAY OF ARRAYS* pretty easily:<BR><BR> ar = Array( _<BR> Array( "Matthew", "Jr. Programmer", 32000.00 ), _<BR> Array( "Ghost", "Java Freak", 21000.00 ), _<BR> Array( "Bill", "Just plain Freak", 1.98 ) _<BR> ) <BR><BR>And, of course, that really is all on one line (the underlines make the multiple physical lines into one logical line).<BR><BR>**************<BR><BR>(2) I know of no FAQ on sorting a multidimensional array. Maybe DG will find the one he is referring to for us???<BR><BR>And you really don&#039;t want to. Doing so is a very very slow and tedious process, as you have to swap all the columns in each pair of swapped rows in a FOR loop. Ugh.<BR><BR>Much better and easier to sort an array-of-arrays (as generated by the code above, for example). There, you can swap rows by just swapping the elements of the outer array!<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts