-- Script for PublishPlot -- Sort the selected plot or front most plot if none selected -- Written by John A. Nairn, Mar 31, 2021 tell application "PublishPlot" -- make sure a document is open activate if number of documents is 0 then display dialog "No open documents" return end if tell front document -- the opened plot needs a data set set iplot to selected plot if iplot is "" then display dialog "Open a document with plotted data and try again" return end if -- get data fro selected plot set xy to sorted data of iplot set npts to number of items in xy -- move to new lists set xpts to {} set ypts to {} repeat with i from 1 to npts set pt to item i of xy set end of xpts to item 1 of pt set end of ypts to item 2 of pt end repeat set pd to {xpts, ypts} set plot data of iplot to pd end tell end tell