Re: Sorting a list of records
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