Skip to content

Pad out Anki Source field for sortability#823

Merged
killergerbah merged 2 commits intokillergerbah:mainfrom
agloo:main
Nov 13, 2025
Merged

Pad out Anki Source field for sortability#823
killergerbah merged 2 commits intokillergerbah:mainfrom
agloo:main

Conversation

@agloo
Copy link
Copy Markdown
Contributor

@agloo agloo commented Nov 12, 2025

With bulk export here I'm doing reviews of entire episodes in order, and I've realized that individual flashcards don't naturally sort in their Anki ordering. This makes it very hard to look through them in chronological order.
More precisely, if we have two source fields that are:
1m00s
1h00m00s
Then the h will alphanumerically sort before the m and we'll get the later card first.
The fix for this is simple--we just need to properly pad out our numerals in the source field. This would give those two timestamps these strings:
00h01m00.0s
01h00m00.0s
We could also pad out the millisecond count on the audio, but not all flashcards will have audio.

This will give us an ordering that works until we get to a 101-hour-long video, or one that has two subtitles .1 seconds apart--both of these limits seem reasonable.

This is changing sourceString() which will affect a few more code sites. As luck would have it those sites correspond to all the cards we create, whether that be in the UI or bulk export or whatever. I figure we'd want the fields consistent across export methods, so I'm not adding any extra args there.

if (fullyPadded) {
let secondsStr: string;
if (nearestTenth) {
// For decimal seconds, pad integer part to 2 digits (e.g., 8.2 -> 08.2, 1 -> 01)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know the comment is referring to the integer part but for clarity it might make sense to write 1 -> 01.0 which represents the actual transformation that will occur.

@killergerbah
Copy link
Copy Markdown
Owner

Sweet thanks

@killergerbah killergerbah merged commit 9c039dc into killergerbah:main Nov 13, 2025
1 check passed
@killergerbah killergerbah added this to the Extension v1.14.0 milestone Nov 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants