5050from arango .typings import Fields , Headers , Json , Jsons , Params
5151from arango .utils import (
5252 build_filter_conditions ,
53+ build_sort_expression ,
5354 get_batches ,
5455 get_doc_id ,
5556 is_none_or_bool ,
5657 is_none_or_int ,
5758 is_none_or_str ,
59+ validate_sort_parameters ,
5860)
5961
6062
@@ -753,6 +755,7 @@ def find(
753755 skip : Optional [int ] = None ,
754756 limit : Optional [int ] = None ,
755757 allow_dirty_read : bool = False ,
758+ sort : Sequence [Json ] = [],
756759 ) -> Result [Cursor ]:
757760 """Return all documents that match the given filters.
758761
@@ -771,16 +774,18 @@ def find(
771774 assert isinstance (filters , dict ), "filters must be a dict"
772775 assert is_none_or_int (skip ), "skip must be a non-negative int"
773776 assert is_none_or_int (limit ), "limit must be a non-negative int"
777+ if sort :
778+ validate_sort_parameters (sort )
774779
775780 skip_val = skip if skip is not None else 0
776781 limit_val = limit if limit is not None else "null"
777782 query = f"""
778783 FOR doc IN @@collection
779784 { build_filter_conditions (filters )}
780785 LIMIT { skip_val } , { limit_val }
786+ { build_sort_expression (sort )}
781787 RETURN doc
782788 """
783-
784789 bind_vars = {"@collection" : self .name }
785790
786791 request = Request (
0 commit comments