diff --git a/pylib/anki/collection.py b/pylib/anki/collection.py index 63ab55e4e..d46fd75d2 100644 --- a/pylib/anki/collection.py +++ b/pylib/anki/collection.py @@ -497,8 +497,22 @@ class Collection: reverse: bool = False, ) -> Sequence[CardId]: """Return card ids matching the provided search. + To programmatically construct a search string, see .build_search_string(). - To define a sort order, see _build_sort_mode(). + + If order=True, use the sort order stored in the collection config + If order=False, do no ordering + + If order is a string, that text is added after 'order by' in the sql statement. + You must add ' asc' or ' desc' to the order, as Anki will replace asc with + desc and vice versa when reverse is set in the collection config, eg + order="c.ivl asc, c.due desc". + + If order is a BuiltinSort.Kind value, sort using that builtin sort, eg + col.find_cards("", order=BuiltinSort.Kind.CARD_DUE) + + The reverse argument only applies when a BuiltinSort.Kind is provided; + otherwise the collection config defines whether reverse is set or not. """ mode = _build_sort_mode(order, reverse) return cast( @@ -512,8 +526,9 @@ class Collection: reverse: bool = False, ) -> Sequence[NoteId]: """Return note ids matching the provided search. + To programmatically construct a search string, see .build_search_string(). - To define a sort order, see _build_sort_mode(). + The order parameter is documented in .find_cards(). """ mode = _build_sort_mode(order, reverse) return cast( @@ -1072,22 +1087,6 @@ def _build_sort_mode( order: Union[bool, str, BuiltinSort.Kind.V], reverse: bool, ) -> _pb.SortOrder: - """Return a SortOrder object for use in find_cards() or find_notes(). - - If order=True, use the sort order stored in the collection config - If order=False, do no ordering - - If order is a string, that text is added after 'order by' in the sql statement. - You must add ' asc' or ' desc' to the order, as Anki will replace asc with - desc and vice versa when reverse is set in the collection config, eg - order="c.ivl asc, c.due desc". - - If order is a BuiltinSort.Kind value, sort using that builtin sort, eg - col.find_cards("", order=BuiltinSort.Kind.CARD_DUE) - - The reverse argument only applies when a BuiltinSort.Kind is provided; - otherwise the collection config defines whether reverse is set or not. - """ if isinstance(order, str): return _pb.SortOrder(custom=order) elif isinstance(order, bool):