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
Retrieving data ...