tell application id "com.figure53.QLab.4" to tell front workspace
if the q list name of current cue list does not contain "###" then return -- guards against applying a sort to a show cue list
set thecues to cues of current cue list as list
set thearray to {} as list
repeat with eachcue in thecues
set end of thearray to {idid:uniqueID of eachcue, qname:q list name of eachcue}
end repeat
end tell
sortlist(thearray)
set thecounter to 1
tell application id "com.figure53.QLab.4" to tell front workspace
repeat ((number of items of thearray)) times
set thesortcue to (first cue of current cue list whose uniqueID is (idid of item thecounter of thearray))
move cue id (uniqueID of thesortcue) of parent of thesortcue to end of parent of thesortcue
set thecounter to thecounter + 1
end repeat
end tell
on sortlist(mylist)
repeat with i from 1 to (count of mylist)
repeat with j from i + 1 to count of mylist
if qname of item j of mylist < qname of item i of mylist then
set temp to item i of mylist
set item i of mylist to item j of mylist
set item j of mylist to temp
end if
end repeat
end repeat
end sortlist
Unfortunately although it will rip through sorting 10 cues, on large cue lists e.g 1000, this is so slow as to be unusable, any suggestions for improvements to the sorting algorithms or any 'a reference to ' tricks??
Mic
tell application id "com.figure53.QLab.4" to tell front workspace
if the q list name of current cue list does not contain "###" then return -- guards against applying a sort to a show cue list
set thecues to cues of current cue list as list
set thearray to {} as list
repeat with eachcue in thecues
set end of thearray to {idid:uniqueID of eachcue, qname:q list name of eachcue}
end repeat
end tell
qsort(thearray, 1, ((number of items of thearray)))
set thecounter to 1
tell application id "com.figure53.QLab.4" to tell front workspace
repeat ((number of items of thearray)) times
set thesortcue to (first cue of current cue list whose uniqueID is (idid of item thecounter of thearray))
move cue id (uniqueID of thesortcue) of parent of thesortcue to end of parent of thesortcue
set thecounter to thecounter + 1
end repeat
end tell
on qsort(array, l, r)
set i to l
set j to r
set v to item ((l + r) div 2) of array -- pivot
repeat while (j > i)
repeat while (qname of item i of array < qname of v)
set i to i + 1
end repeat
repeat while (qname of item j of array > qname of v)
set j to j - 1
end repeat
if (not i > j) then
tell array to set {item i, item j} to {item j, item i} -- swap
set i to i + 1
set j to j - 1
end if
end repeat
if (l < j) then qsort(array, l, j)
if (r > i) then qsort(array, i, r)
end qsortThis is a potentially dangerous script as it is not undoable. Undoing a sort will delete the sorted cues (one by one!). Because of this, I have retained the sort authorisation string "###." Your group's name must include this string. For QLab 4 change all QLab.5 references to QLab.4
tell application id "com.figure53.QLab.5" to tell front workspace
set theGroup to last item of (selected as list)
if q type of theGroup is not "group" then
display alert "Selected cue is not a group cue "
return
end if
if the q list name of theGroup does not contain "###" then -- guards against applying a sort to a show cue list
display alert "Selected Group is not authorised for sorting"
return
end if
display dialog "This sort is not undoable! Proceed?"
set thecues to cues of theGroup as list
set thearray to {} as list
repeat with eachcue in thecues
set end of thearray to {idid:uniqueID of eachcue, qname:q list name of eachcue}
end repeat
end tell
qsort(thearray, 1, ((number of items of thearray)))
set thecounter to 1
tell application id "com.figure53.QLab.5" to tell front workspace
repeat ((number of items of thearray)) times
set thesortcue to (first cue of theGroup whose uniqueID is (idid of item thecounter of thearray))
move cue id (uniqueID of thesortcue) of parent of thesortcue to end of parent of thesortcue
set thecounter to thecounter + 1
end repeat
end tell
on qsort(array, l, r)
set i to l
set j to r
set v to item ((l + r) div 2) of array -- pivot
repeat while (j > i)
repeat while (qname of item i of array < qname of v)
set i to i + 1
end repeat
repeat while (qname of item j of array > qname of v)
set j to j - 1
end repeat
if (not i > j) then
tell array to set {item i, item j} to {item j, item i} -- swap
set i to i + 1
set j to j - 1
end if
end repeat
if (l < j) then qsort(array, l, j)
if (r > i) then qsort(array, i, r)
end qsort