-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSortText.scpt
More file actions
34 lines (33 loc) · 1.22 KB
/
Copy pathSortText.scpt
File metadata and controls
34 lines (33 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
--https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/ManipulateText.html
--https://www.macosxautomation.com/applescript/sbrt/sbrt-05.html
on simple_sort(my_list)
set the index_list to {}
set the sorted_list to {}
repeat (the number of items in my_list) times
set the low_item to ""
repeat with i from 1 to (number of items in my_list)
if i is not in the index_list then
set this_item to item i of my_list as text
if the low_item is "" then
set the low_item to this_item
set the low_item_index to i
else if this_item comes before the low_item then
set the low_item to this_item
set the low_item_index to i
end if
end if
end repeat
set the end of sorted_list to the low_item
set the end of the index_list to the low_item_index
end repeat
return the sorted_list
end simple_sort
on splitText(theText, theDelimiter)
set AppleScript's text item delimiters to theDelimiter
set theTextItems to every text item of theText
set AppleScript's text item delimiters to " "
return theTextItems
end splitText
set theText to the clipboard
set the textToSort to splitText(theText, space)
set the clipboard to simple_sort(the textToSort) as text