Re: Sorting a list of Lists
Re: Sorting a list of Lists
- Subject: Re: Sorting a list of Lists
- From: has <email@hidden>
- Date: Thu, 8 Jul 2004 18:48:31 +0100
Andrew Donnelly wrote:
What I need the sort to do is this. I have a list that contains the
bounds of text boxes on an InDesign page that looks like this.
{{1.59, 2.99, 1.768, 3.586}, {1.31, 2.99, 1.486, 8.004}, {1.035, 2.990,
1.205, 8.004} }
I would like for it to look like this when run through a sort routine.
{{1.035, 2.99, 1.205, 8.004}, {1.31, 2.99, 1.486, 8.004}, {1.59, 2.99,
1.768, 3.586}}
There's a pretty robust sortListOfLists command in the List library
at AppleMods <
http://applemods.sourceforge.net/> that will do this
for you:
property _Loader : run application "LoaderServer"
----------------------------------------------------------------------
-- DEPENDENCIES
property _List : missing value
on __load__(loader)
set _List to loader's loadLib("List")
end __load__
----------------------------------------------------------------------
__load__(_Loader's makeLoader())
_List's sortListOfLists({{1.59, 2.99, 1.768, 3.586}, {1.31, 2.99,
1.486, 8.004}, {1.035, 2.99, 1.205, 8.004}}, {2, 1})
--> {{1.035, 2.99, 1.205, 8.004}, {1.31, 2.99, 1.486, 8.004},
{1.59, 2.99, 1.768, 3.586}}
While it's not immune to stack overflows (caused by too many
recursive handler calls), it's the chances of encountering one are
vanishingly small.
HTH
has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.