Array's awry

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
RossG
Posts: 247
Joined: Thu Jan 08, 2015 7:38 am

Array's awry

Post by RossG » Tue Jun 28, 2016 2:32 am

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?
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10322
Joined: Wed May 06, 2009 2:28 pm

Re: Array's awry

Post by dunbarx » Tue Jun 28, 2016 2:41 am

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

RossG
Posts: 247
Joined: Thu Jan 08, 2015 7:38 am

Re: Array's awry

Post by RossG » Tue Jun 28, 2016 3:23 am

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.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Array's awry

Post by mwieder » Tue Jun 28, 2016 7:25 pm

"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

Post Reply