From what I can tell, the plugin API can only execute advanced queries, and doesn’t have the ability to run transforms. That means that sorting has to be done by the plugin itself.
The way I’ve handled this is by expecting the data returned from the query to be in a certain structure, part of which is the value on which to sort on. Basically, the there needs to be a property of the query result called meta which has a property called sortKey.