• 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 records
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sorting a list of records


  • Subject: Re: Sorting a list of records
  • From: Axel Luttgens <email@hidden>
  • Date: Wed, 25 Aug 2010 09:44:24 +0200

Le 25 août 2010 à 06:49:27, email@hidden a écrit :

> The merge sort seems more complicated and a lot slower. Am I missing something?
>
> set listToSort to {}
> repeat with x from 1 to 100
> 	set myData to random number from 1 to 10
> 	set the end of listToSort to myData
> end repeat
> copy listToSort to originalList
>
> set sortAListStart to current date
> set sortedLists to SortAList()
> set sortAListEnd to current date
> set sortAListElapse to sortAListEnd - sortAListStart
> set mergeStart to current date
> mergeSort(listToSort, 1, -1)
> set mergeEnd to current date
> set mergeElapse to mergeEnd - mergeStart
>
> [...]

Hello Ed,

Have you tried with longer lists?

That said, it seems that the execution speed of your SortAList() handler may be greatly enhanced by prefixing each occurrence of a property with "my" (as in: my sortedList, my calcList, my listToSort...).
Yeah, that old trick again. ;-)

Here, with that slight modification, SortAList() and mergeSort() have similar execution times for lists up to about 500 items.

Axel


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

This email sent to email@hidden

References: 
 >Re: Sorting a list of records (From: "Nigel Garvey" <email@hidden>)
 >Re: Sorting a list of records (From: "email@hidden" <email@hidden>)

  • Prev by Date: Re: Sorting a list of records
  • Next by Date: Re: One more thing...
  • Previous by thread: Re: Sorting a list of records
  • Next by thread: One more thing...
  • Index(es):
    • Date
    • Thread