From 183621ea007b2a3c43fc263611c6ac5ae8366315 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Thu, 23 Nov 2023 11:37:49 +0800 Subject: [PATCH] :art: Sort by Due asc on the flashcard management UI https://github.com/siyuan-note/siyuan/pull/9673#issuecomment-1823003087 --- kernel/model/flashcard.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go index 9157571e3..1d041c609 100644 --- a/kernel/model/flashcard.go +++ b/kernel/model/flashcard.go @@ -309,7 +309,12 @@ func GetDeckFlashcards(deckID string, page int) (blocks []*Block, total, pageCou } func getCardsBlocks(cards []riff.Card, page int) (blocks []*Block, total, pageCount int) { - sort.Slice(cards, func(i, j int) bool { return cards[i].BlockID() < cards[j].BlockID() }) + // sort by due date asc https://github.com/siyuan-note/siyuan/pull/9673 + sort.Slice(cards, func(i, j int) bool { + due1 := cards[i].(*riff.FSRSCard).C.Due + due2 := cards[j].(*riff.FSRSCard).C.Due + return due1.Before(due2) + }) const pageSize = 20 total = len(cards) @@ -329,13 +334,6 @@ func getCardsBlocks(cards []riff.Card, page int) (blocks []*Block, total, pageCo return } - // sort by due date asc https://github.com/siyuan-note/siyuan/pull/9673 - sort.Slice(cards, func(i, j int) bool { - due1 := cards[i].(*riff.FSRSCard).C.Due - due2 := cards[j].(*riff.FSRSCard).C.Due - return due1.Before(due2) - }) - var blockIDs []string for _, card := range cards { blockIDs = append(blockIDs, card.BlockID())