• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Sorting a list of Lists
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Prev by Date: Re: Rounding numbers in Applescript
  • Next by Date: Re: Script Objects in Libraries
  • Previous by thread: Re: Sorting a list of Lists
  • Next by thread: Re: Sorting a list of Lists
  • Index(es):
    • Date
    • Thread