To Add sort field on grid using form data source in axapta you can do following code in form data source table on execute query method.
public void executeQuery()
{;
InventTable_ds.query().dataSourceNo(1).sortClear();
InventTable_ds.query().dataSourceNo(1).addSortField(fieldNum(CustTable,CustGroup), sortOrder::Ascending);
super();
}
After adding code you can call in modified method of control or init method of form.
public boolean modified()
{
boolean ret;
;
ret = super();
InventTable_ds.executeQuery();
return ret;
}