Sort using a custom comparator: Difference between revisions
m
→{{header|AppleScript}}: →Vanilla: New sort handler URL, tidy-up.
(→{{header|Pascal}}: added example) |
m (→{{header|AppleScript}}: →Vanilla: New sort handler URL, tidy-up.) |
||
Line 879:
===Vanilla===
<syntaxhighlight lang="applescript">use AppleScript version "2.3.1" -- OS X 10.9 (Mavericks) or later
use sorter : script
"Custom Iterative Ternary Merge Sort" --<www.macscripter.net/t/timsort-and-nigsort/71383/3>
set listOfText to words of "now is the time for all good men to come to the aid of the party"▼
-- Sort customiser.
script descendingByLengthThenAscendingLexicographically
on isGreater(a, b)
set lenA to
set lenB to
if (lenA = lenB) then return (a > b)
end isGreater
end script
▲set listOfText to words of "now is the time for all good men to come to the aid of the party"
tell sorter to ¬
return listOfText</syntaxhighlight>
|