Skip to content

qjoin - modifier - sort the final collection #7

@FabienArcellier

Description

@FabienArcellier

the sort function sorts the result of the query according to a predicate modeled on the sorted function in python

sorting by simple key

sorting by simple key is done on the sorting of one of the attributes of the base collection

qjoin.on(persons) \
     .join(cities, key='city') \
     .sort(key='city') \
     .all()

sorting by artificial key

le tri par clé artificielle s'effectue sur l'attribut d'un élément de n'importe quelle collection, que ce soit la collection de base ou les collections de jointures.

qjoin.on(persons) \
     .join(cities, key='city') \
     .sort(key=lambda p, c: p.city) \
     .all()

You have to handle the case in the predicate where a join can fail. If some elements of the persons collection do not have joins, then the value None must be treated for the c parameter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions