Sorting
How to sort selection query results.
db.sort()
db.sort()
Used for sorting database query results. You can either sort the results in a decending or an ascending order.
Usage
[select query object].db.sort(db.[desc/asc]([column]))
Parameters:
Either
db.desc
ordb.asc
.
Example
&basic
db_model MyModel:
id = db.col(db.int, db.pk)
number = db.col(db.int)
column = db.col(...)
...
# Selects all rows in MyModel where the column "coumn" is set to "text".
# Sorts the rows in descending order by the column "number".
results = MyModel.db.get_by(column='text').db.sort(db.desc(MyModel.number))
...
Last updated