Ok, try to put some sort of order.
First, it is not recommended to physically sort the table. In fact, most RDBMS do not even provide you with this feature. As a rule, one, in order not to force a full scan of the table (sometimes called natural scanning), creates indexes in the fields of the table on which it considers that the table will be sorted / searched.
As you can see, the first step in sorting a table is usually to create an index. This is a separate step, it is done once, usually at, let them say, "development time". After that, the database engine will take care of automatically updating indexes.
The creation index is performed by you (the developer), using (usually) not Delphi (or any other development tool), but the administration tool of your RDBMS (the same tool that you used when you created your table).
If your "database engine" is actually a Delphi memory dataset (TClientDataSet), then you will go to the IndexDefs property, open it, add a new index and set the appropriate properties. An interesting property in our discussion of Fields . Install it on Payee;Payer . Set also Name , for example. "IdxPayee". If you are using another TDataSet descendant, consult the docs of your database engine or ask another question here on SO.com for details.
Now to use the index. (IOW, sort the table as you say). In your program (either at development time or at run time), set " IndexName " in your table to "idxPayee" or any other valid name you gave, or set IndexFieldNames to Payee;Payer .
Once again, note that the above example is based on the TClientDataSet. What you must save from the above (if you are not using it) is that an index must already be created to use it.
In addition, to answer your question, yes, there are some types of βtablesβ (descendants of TDataSet in Delphi terminology) that support sorting either using the Sort method (or the like) or through the SortFields property,
But at present, usually when you are working with a SQL server, the preferred solution is to create indexes using the appropriate administration tool, and then release (using Delphi) SELECT * FROM myTable ORDER BY Field1 .
NTN