The sorted() method will sort the records in a recordset. Called without arguments, the _order attribute of the model will be used. Otherwise, a function can be passed to compute a comparison key in the same fashion as the Python built-in sorted(sequence, key) function. The reverse keyword argument is also supported.
A note about performance
When the default _order parameter of the model is used, the sorting is delegated to the database and a new SELECT function is performed to get the order. Otherwise, the sorting is performed by Odoo. Depending on what is being manipulated, and depending on the size of the recordsets, there can be some important performance differences.
When the default _order parameter of the model is used, the sorting is delegated to the database and a new SELECT function is performed to get the order. Otherwise, the sorting is performed by Odoo. Depending on what is being manipulated, and depending on the size of the recordsets, there can be some important performance differences.