on my Leopard system all sorting mechanism stopped working. Can someone help?
E.g. Hoare’s QuickSort …
on Qsort(array, leftEnd, rightEnd) -- Hoare's QuickSort Algorithm
script a
property l : array
end script
set {i, j} to {leftEnd, rightEnd}
set v to item ((leftEnd + rightEnd) div 2) of a's l -- pivot in the middle
repeat while (j > i)
repeat while (item i of a's l < v)
set i to i + 1
end repeat
repeat while (item j of a's l > v)
set j to j - 1
end repeat
if (not i > j) then
tell a's l to set {item i, item j} to {item j, item i} -- swap
set {i, j} to {i + 1, j - 1}
end if
end repeat
if (leftEnd < j) then Qsort(a's l, leftEnd, j)
if (rightEnd > i) then Qsort(a's l, i, rightEnd)
end Qsort
Thanks
Tobias
Model: MacMini 2.26 GHz Intel Core 2 Duo
AppleScript: 2.0.1
Browser: Safari 531.21.10
Operating System: Mac OS X (10.5)
Your list has been sorted lexically, so presumably the list items are texts, not integers. If you want them sorted numerically, either coerce them to integers first or use ‘considering numeric strings’: