When you sort the data in a table, query, form, or report, you can save the sort order with the object.
web2py comes with a Database Abstraction Layer (DAL), an API that maps Python objects into database objects such as queries, tables, and records.
The DAL dynamically generates the SQL in real time using the specified dialect for the database back end, so that you do not have to write SQL code or learn different SQL dialects (the term SQL is used generically), and the application will be portable among different types of databases.
A partial list of supported databases is show in the table below.
The default sort order is applied to the data in the query or report when no other sort order is specified.
When you save a table, query, form, or report while the data is sorted, the sort order is automatically saved when you save the object. When you create a sort order, you are actually changing the design of the object.
If you want the last-applied sort order to be automatically applied the next time that you open the object, set the Order By On Load property of the object to Yes.To set this property, perform the following steps while the object is open in Design view.Because the last-applied sort order can change whenever someone sorts an object and then saves it, you may want to define a default sort order.A default sort order is part of the design of the object, and does not change when a different sort order is applied.You can only specify a default sort order for a query or report.Although the default sort order is not overwritten by the current or last-applied sort order, it comes into effect only when the current or last-applied sort order is removed.