--ランダムな数値からなるリストを作成
set N to {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
set numList to {}
repeat 300 times
set end of numList to (some item of N) * 100 + (some item of N) * 10 + (some item of N)
end repeat
--set T to current date --時間計測開始
repeat 1 times --秒単位の計測しかできないので時間計測の制度をあげるため
sort_list(a reference to numList)
end repeat
--(current date) - T --時間計測終了
--以下がソートのルーチンになります
on sort_list(theList)
set {sortList, i} to {{item 1 of theList}, 2}
repeat (count theList) - 1 times
set {aItem, A, Z} to {item i of theList, 1, i}
repeat until A = Z
if item ((A + Z) div 2) of sortList > aItem then
set Z to (A + Z) div 2
else
set A to (A + Z) div 2 + 1
end if
end repeat
if A = 1 then
set beginning of sortList to aItem
else if A = i then
set end of sortList to aItem
else
set sortList to items 1 thru (A - 1) of sortList & {aItem} & (items A thru -1 of sortList)
end if
set i to i + 1
end repeat
return sortList
end sort_list