Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sort a list of lists




On Nov 16, 2006, at 4:36 PM, CYB wrote:

Hi everyone,

I have a variable number of objects in a page – for example 4 rectangles- and I need to know which one is the left-top most, (I’m scripting InDesign CS2) so I get the geometric bounds of all this objects and I get a list of lists
My typical list looks like {{5.0, 120.0, 40.0, 169.0}, {10.0, 10.0, 50.0, 59.0}, {70.0, 20.0, 110.0, 69.0}, {70.0, 80.0, 110.0, 128.0}}
So basically I need to compare the first 2 items (y, x) of every list in that main list, in this example the order (Left/Right, clock wise) is
1.- second list, 2.- first list, 3.- third list, 4.- fourth list


I think, at the first moment that it’s pretty simple, but for my disgrace I found that after many hours of try to write an algorithm to to this, I have nothing, :-((

Anyone have something in this way or can someone point me in the right direction?
Your help will be appreciated.

Not clear from your description what results you want, but if what you want is a measure of which window is
closest to (0,0), then what you want is to order them by the sum of the squares of the first two numbers,
which in this case would give you:


( 10, 10 )
( 70, 20 )
( 70, 80 )
( 5, 120 )

_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-users/email@hidden
Archives: http://lists.apple.com/mailman//archives/applescript-users

This email sent to email@hidden
References: 
 >Sort a list of lists (From: CYB <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.