Re: Sort a List with Integers & Letters ( Reverse Speed Results When Using TEXT)
Re: Sort a List with Integers & Letters ( Reverse Speed Results When Using TEXT)
- Subject: Re: Sort a List with Integers & Letters ( Reverse Speed Results When Using TEXT)
- From: "Nigel Garvey" <email@hidden>
- Date: Thu, 12 Apr 2007 18:07:29 +0100
Bill Hernandez wrote on Thu, 12 Apr 2007 00:33:41 +0000:
>The original tests I ran the other day showed when sorting 1000
>random numbers whose value was between (1 and 1000)
>MERGE_SORT was absolutely lightning quick
>with QUICK_SORT in a distant second place, and
>ASCII_SORT in an even more distant 3rd place, out at the far end of
>the galaxy
[snip]
>In the process of sorting some text paths (11 to 14 paths) ranging
>in length between 123 and 178 characters the reverse has come to pass.
>
>How BIZARRE!
>
>As the length of the strings increase MERGE_SORT absolutely dies...
>and adding a few more strings really kills it...
>ASort 11 --> 0.051 seconds -- ASCII_SORT
>QSort 11 --> 0.056 seconds -- QUICK_SORT
>MSort 11 --> 4.723 seconds -- MERGE_SORT
>
>ASort 11 --> 0.045 seconds
>QSort 11 --> 0.038 seconds
>MSort 11 --> 4.399 seconds
Etc.
Hi, Bill.
I can't explain your results at all. When I run your test script with my
own (TextWrangler) documents, or with your own list of strings hard-wired
in, I get results broadly in line with what I'd expect for only eleven items:
ASort 11 --> 0.02 seconds
QSort 11 --> 0.019 seconds
MSort 11 --> 0.018 seconds
ASort 11 --> 0.021 seconds
QSort 11 --> 0.018 seconds
MSort 11 --> 0.018 seconds
ASort 11 --> 0.022 seconds
QSort 11 --> 0.019 seconds
MSort 11 --> 0.018 seconds
Etc.
I'm mystified. :\ Mind you, I get much improved results for all three
sorts if the BBEdit (or TextWrangler) 'tell' block is ended immediately
after the first repeat block instead of enclosing the entire 'run' section.
A small issue with your test script:
> repeat 10 times
> set aList to aResults
> set t to (GetMilliSec)
> tell me to set aList to bh_ASCII_Sort(aList) -- Sort all items of
>aList
> set T1 to "ASort " & NoOfItems & " --> " & ((GetMilliSec) - t) /
>1000 & " seconds " --> (for 11 paths -> .077 seconds)
Ditto bh_QSort()
Ditto bh_Merge_Sort()
> end repeat
'set aList to aResults' sets aList to the same physical list as aResults.
Since my merge sort is an "in place" sort that rearranges the items in
the list rather than returning a sorted copy, aResults itself will be
sorted after the first call to bh_Merge_Sort() and the 2nd to 10th
iterations of the repeat will be sorting an already sorted list. Ideally,
you should use 'copy aResults to aList' to preserve the original list.
NG
_______________________________________________
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