order_byΒΆ

You can use order_by clauses with the following queries:

To order the results by a certain column (ascending):

await Band.select().order_by(
    Band.name
)

To order by descending:

await Band.select().order_by(
    Band.name,
    ascending=False
)

You can order by multiple columns, and even use joins:

await Band.select().order_by(
    Band.name,
    Band.manager.name
)