We could need a way to query in script the order of current sorting.
Ascending vs. descending.
I imagine that this could return a JSON array of fieldname / sort order pairs.
EDIT: or a JSON array of JSON Objects with fieldname, sort order, value list if any, encoding options, etc
Along with a way to feed it back into a Sort to achieve the same.
Retrieving data ...