Skip to content

Added settings keys sorting - #533

Merged
seanprashad merged 3 commits into
seanprashad:mainfrom
cub-uanic:master
Aug 9, 2026
Merged

Added settings keys sorting#533
seanprashad merged 3 commits into
seanprashad:mainfrom
cub-uanic:master

Conversation

@cub-uanic

Copy link
Copy Markdown
Contributor

I'm using Git to store my progress in dotfiles and share them between several hosts.
Sometimes, on different hosts, I'm getting the keys in json in a different order.
This makes it difficult to understand exactly what was changed (while in reality, it could be just one line), and also makes diffs larger.
As a solution, I suggest always sort the keys of the settings object.

(the idea is the same as I proposed in philc/vimium#4764)

@seanprashad seanprashad left a comment

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.

Hi @cub-uanic! To sync progress across multiple hosts, you can sign in with your GitHub account:

Image

Does this fit your use case? This was meant to replace the export/import functionality

@cub-uanic

Copy link
Copy Markdown
Contributor Author

Hi @seanprashad,
Yes, I know about possibility to sign in via GitHub.
However, I'm old-fashioned :) and would like to store and manage my progress locally.

seanprashad

This comment was marked as duplicate.

@seanprashad seanprashad left a comment

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.

Change makes sense - just one small adjustment to ensure exports won't be malformed

Comment thread src/components/questions/QuestionsTable.tsx Outdated
Co-authored-by: Sean Prashad <13009507+seanprashad@users.noreply.github.com>
Signed-off-by: Oleh Kostiuk <cub.uanic@gmail.com>

@seanprashad seanprashad left a comment

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.

Thank you very much!

@cub-uanic

Copy link
Copy Markdown
Contributor Author

Seems we're lost the key point - sorting the entire payload, not just some of its keys:

const payload = {
    completed: [...completed].sort((a, b) => a - b),
    starred: [...starred].sort((a, b) => a - b),
    notes, solvedDates, reminders
}.sort();

I'm about the last line (untested)

seanprashad added a commit that referenced this pull request Aug 9, 2026
Sort completed/starred numerically at export time and end the file
with a trailing newline, so exports are byte-stable across hosts for
users who keep them in version control (#533). Add tests that assert
the export round-trips through import, is sorted regardless of
completion order, and ends with a newline — the round-trip test also
guards against malformed (non-JSON) export payloads.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
seanprashad added a commit that referenced this pull request Aug 9, 2026
Make progress export deterministic and cover it with tests

Sort completed/starred numerically at export time and end the file
with a trailing newline, so exports are byte-stable across hosts for
users who keep them in version control (#533). Add tests that assert
the export round-trips through import, is sorted regardless of
completion order, and ends with a newline — the round-trip test also
guards against malformed (non-JSON) export payloads.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@seanprashad

Copy link
Copy Markdown
Owner

Seems we're lost the key point - sorting the entire payload, not just some of its keys:

const payload = {
    completed: [...completed].sort((a, b) => a - b),
    starred: [...starred].sort((a, b) => a - b),
    notes, solvedDates, reminders
}.sort();

I'm about the last line (untested)

Did you see #533 (comment)? There's also instructions to run the website locally: https://github.com/seanprashad/leetcode-patterns#contributing

@cub-uanic

Copy link
Copy Markdown
Contributor Author

Was in rush and missed it 🫡

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