Page 1 of 1

Array's awry

Posted: Tue Jun 28, 2016 2:32 am
by RossG
I have an array:

1 2
2 2
3 1
4 1
6 1
8 1
11 1

but when combined I get

2,1,2,1,1,1,1.

What's up Doc?

Re: Array's awry

Posted: Tue Jun 28, 2016 2:41 am
by dunbarx
Hi.

Not sure what exactly what you did, but step through this and write back.

Code: Select all

on mouseUp
   put "2" into myArray[1]
   put "2" into myArray[2]
   put "1" into myArray[3]
   put "1" into myArray[6]
   put "1" into myArray[8]
   put "1" into myArray[11]
   combine myArray with return and comma
   sort myArray numeric by item 1 of each
end mouseUp
Note that unless you sort in the clear, an array has no obligation to maintain any order at all, regardless of how you assemble that array.

Craig Newman

Re: Array's awry

Posted: Tue Jun 28, 2016 3:23 am
by RossG
Craig
A bit befuddled this morning I forgot what I
knew about this subject but as the mist lifted
I realized that I had to do a bit of coding to
get the result I wanted.

So much to learn, so little time.

Thanks for taking the time.

Re: Array's awry

Posted: Tue Jun 28, 2016 7:25 pm
by mwieder
"Ad hoc, ad loc and quid pro quo.
So little time — so much to know!"
-Jeremy Hillary Boob
Yellow Submarine
https://en.wikipedia.org/wiki/Jeremy_Hillary_Boob