qgis-sample-QgsOrderByDialog.py
from qgis.gui import QgsOrderByDialog
from qgis.utils import iface
layer = iface.activeLayer()
order_by_dialog = QgsOrderByDialog(layer)
order_by = layer.rendererV2().orderBy()
clauses = order_by.list()
for clause in clauses:
print('Expression: ' + clause.expression().expression())
print('Ascending?: ' + str(clause.ascending()))
print('nulls first? ' + str(clause.nullsFirst()))
print('Dump: ' + clause.dump())
order_by_dialog.setOrderBy(order_by)
order_by_dialog.show()