--ランダムな数値からなるリストを作成
set N to {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
set numList to {}
repeat 500 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 --秒単位の計測しかできないので時間計測の制度をあげるため
set sortListID to sort_list(numList)
end repeat
--(current date) - T --時間計測終了
--実データ取得には sortListID を介して参照する
set sortList to {}
repeat with aID in sortListID
set end of sortList to item aID of numList
end repeat
get sortList
--以下がIDを返すソートのルーチンになります
on sort_list(theList)
set {sortListID, I} to {{1}, 2}
repeat (count theList) - 1 times
set {aItem, A, Z} to {item I of theList, 1, I}
repeat until A = Z
if item (item ((A + Z) div 2) of sortListID) of theList > 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 sortListID to I
else if A = I then
set end of sortListID to I
else
set sortListID to items 1 thru (A - 1) of sortListID & {I} & (items A thru -1 of sortListID)
end if
set I to I + 1
end repeat
return sortListID
end sort_list