sorting data on a dbgrid lazarus / 16-Databases ---------------------------------------------------------------------- maryg · 2016-08-19 16:02 i would like to sort data on the dbgrid so as to print the data separately. any ideas????? ---------------------------------------------------------------------- derek.john.evans · 2016-08-19 17:34 TDataSet.IndexName For more complex sorting you need to add field indexs to the DataSet using AddIndex(). (Note, this method is difference for each dataset type). This gives you the option of creating descending index's. Most code I've seen encode the indexname with the fieldname + a order postfix. The code I use searches the indexes for the require type (based on fieldname/order), and creates one if not found. Some dataset's will cache these index's (eg: Dbs), others will not (eg: TBufDataSet). Hope that helps