Skip to content

Sort sequences in sort_maps to fix non-deterministic HashSet snapshots#876

Merged
max-sixty merged 1 commit intomitsuhiko:masterfrom
max-sixty:sorted-hashset
Feb 13, 2026
Merged

Sort sequences in sort_maps to fix non-deterministic HashSet snapshots#876
max-sixty merged 1 commit intomitsuhiko:masterfrom
max-sixty:sorted-hashset

Conversation

@max-sixty
Copy link
Collaborator

Summary

  • sort_maps only sorted Content::Map, but HashSet serializes as Content::Seq via serde, leaving snapshot output non-deterministic across recompilations
  • Extend sort_maps() to also sort Content::Seq items using the same key-based comparison
  • Extract shared cmp_as_key helper to deduplicate comparison logic between Map and Seq sorting
  • Update set_sort_maps / sort_maps doc comments to reflect the expanded scope

Closes #211

Test plan

  • Added test_sort_maps_sorts_hashset verifying both HashSet and HashMap produce deterministic sorted output
  • All existing tests pass with --all-features

This was written by Claude Code on behalf of max-sixty

…shots

`sort_maps` only sorted `Content::Map` but `HashSet` serializes as
`Content::Seq`, leaving its snapshot output non-deterministic across
recompilations. Extend `sort_maps` to also sort `Content::Seq` items.

Closes mitsuhiko#211

Co-Authored-By: Claude <noreply@anthropic.com>
@max-sixty max-sixty merged commit ebe5a6e into mitsuhiko:master Feb 13, 2026
15 checks passed
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.

Deterministic sort order for HashSet (reopen issue #53)

1 participant