Skip to content

When writing the JSON file, print the top-level keys (version numbers) in SemVer order (not lexicographical order)#66

Closed
DilumAluthge wants to merge 7 commits into
mainfrom
dpa/sort-ordereddict
Closed

When writing the JSON file, print the top-level keys (version numbers) in SemVer order (not lexicographical order)#66
DilumAluthge wants to merge 7 commits into
mainfrom
dpa/sort-ordereddict

Conversation

@DilumAluthge
Copy link
Copy Markdown
Member

@DilumAluthge DilumAluthge commented Apr 17, 2026

Currently, we use JSON.jl's default sorting, which is to sort every dict in lexicographical order when printing. This is fine for e.g. the file_dict, but for the top-level keys (version numbers), this is less than optimal, because it means that the versions get printed in the order e.g. 1.0, 1.1, 1.10, 1.11, 1.12, 1.13, 1.2, 1.3, 1.4, ....

So, this PR turns off the default JSON.jl sorting, and then explicitly sorts things the way we want. For top-level keys (version numbers), we parse them as VersionNumbers and sort them in SemVer order. For other dicts, we manually do sort! to sort them in lexicographical order.

Other changes

I also included some smaller changes in this PR, let me know if you want me to split any of them out into their own separate PR:

  • Do a full Pkg.update().
  • Project.toml: Change the version number from 0.1.0 to 0.1.0-DEV.
  • Project.toml: Add [compat] entries for all non-stdlib direct deps.
  • Remove all uses of implicit imports; use explicit imports instead.
  • Add a very basic Makefile so that we can just do make versions.json (just for convenience).

@DilumAluthge
Copy link
Copy Markdown
Member Author

This is ready for review, but I want to do a full build locally to make sure it looks right.

@DilumAluthge DilumAluthge changed the title When writing the JSON file, print dict keys in a deterministic order (by using OrderedDict) When writing the JSON file, print dict keys in a deterministic order (by using OrderedDict), and customize the sort order Apr 17, 2026
@DilumAluthge DilumAluthge force-pushed the dpa/sort-ordereddict branch 3 times, most recently from 31a120f to 8ac8137 Compare April 17, 2026 08:42
@DilumAluthge DilumAluthge force-pushed the dpa/sort-ordereddict branch from 8ac8137 to 51876ee Compare April 17, 2026 08:43
@DilumAluthge DilumAluthge changed the title When writing the JSON file, print dict keys in a deterministic order (by using OrderedDict), and customize the sort order When writing the JSON file, print the top-level keys (version numbers) in SemVer order (not lexicographical order) Apr 17, 2026
@DilumAluthge DilumAluthge marked this pull request as ready for review April 17, 2026 09:03
@DilumAluthge DilumAluthge marked this pull request as draft April 18, 2026 14:04
@DilumAluthge
Copy link
Copy Markdown
Member Author

I initially wanted to merge this separately from #67, but I think this PR and #67 are a little too closely linked, so I'm going to combine them.

Closing this PR, and I'll fold these changes into #67.

@DilumAluthge DilumAluthge deleted the dpa/sort-ordereddict branch April 18, 2026 14:07
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.

1 participant