Sorting is allowed when querying the workflow API
as described in
but seems that the list of variables that allow sorting is hardcoded on Activiti:
on the method
private void orderQuery(TaskQuery taskQuery, OrderBy orderBy)
I have the requirement from a customer to allow sorting on custom variables.