Pad out Anki Source field for sortability#823
Merged
killergerbah merged 2 commits intokillergerbah:mainfrom Nov 13, 2025
Merged
Pad out Anki Source field for sortability#823killergerbah merged 2 commits intokillergerbah:mainfrom
killergerbah merged 2 commits intokillergerbah:mainfrom
Conversation
killergerbah
approved these changes
Nov 12, 2025
common/util/util.ts
Outdated
| if (fullyPadded) { | ||
| let secondsStr: string; | ||
| if (nearestTenth) { | ||
| // For decimal seconds, pad integer part to 2 digits (e.g., 8.2 -> 08.2, 1 -> 01) |
Owner
There was a problem hiding this comment.
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.
Owner
|
Sweet thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.