diff --git a/ftl/core/deck-config.ftl b/ftl/core/deck-config.ftl index ad70935c4..3f94a327c 100644 --- a/ftl/core/deck-config.ftl +++ b/ftl/core/deck-config.ftl @@ -113,6 +113,8 @@ deck-config-sort-order-card-template-then-random = Card template, then random deck-config-sort-order-lowest-position = Ascending position deck-config-sort-order-highest-position = Descending position deck-config-sort-order-random = Random +deck-config-sort-order-template-then-gather = Card template, then order gathered +deck-config-sort-order-gather = Order gathered deck-config-new-review-priority = New/review priority deck-config-new-review-priority-tooltip = When to show new cards in relation to review cards. deck-config-interday-step-priority = Interday learning/review priority diff --git a/proto/anki/deckconfig.proto b/proto/anki/deckconfig.proto index 224ddad87..9f4c3ec90 100644 --- a/proto/anki/deckconfig.proto +++ b/proto/anki/deckconfig.proto @@ -43,6 +43,10 @@ message DeckConfig { NEW_CARD_SORT_ORDER_LOWEST_POSITION = 3; NEW_CARD_SORT_ORDER_HIGHEST_POSITION = 4; NEW_CARD_SORT_ORDER_RANDOM = 5; + // Sorts by template, preserving original gather order. + NEW_CARD_SORT_ORDER_TEMPLATE_ONLY = 6; + // Preserves original gather order (eg deck order) + NEW_CARD_SORT_ORDER_NO_SORT = 7; } enum ReviewCardOrder { REVIEW_CARD_ORDER_DAY = 0; diff --git a/rslib/src/scheduler/queue/builder/sorting.rs b/rslib/src/scheduler/queue/builder/sorting.rs index 6777e6a95..225d0c3fe 100644 --- a/rslib/src/scheduler/queue/builder/sorting.rs +++ b/rslib/src/scheduler/queue/builder/sorting.rs @@ -26,6 +26,14 @@ impl QueueBuilder { self.new.iter_mut().for_each(NewCard::hash_id_and_mtime); self.new.sort_unstable_by(new_hash) } + NewCardSortOrder::TemplateOnly => { + // stable sort to preserve gather order + self.new + .sort_by(|a, b| a.template_index.cmp(&b.template_index)) + } + NewCardSortOrder::NoSort => { + // preserve gather order + } } } } diff --git a/ts/deck-options/DisplayOrder.svelte b/ts/deck-options/DisplayOrder.svelte index 7a23e4ca4..3ac1c9c9f 100644 --- a/ts/deck-options/DisplayOrder.svelte +++ b/ts/deck-options/DisplayOrder.svelte @@ -31,6 +31,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html tr.deckConfigSortOrderLowestPosition(), tr.deckConfigSortOrderHighestPosition(), tr.deckConfigSortOrderRandom(), + tr.deckConfigSortOrderTemplateThenGather(), + tr.deckConfigSortOrderGather(), ]; const reviewOrderChoices = [ tr.deckConfigSortOrderDueDateThenRandom(),