Skip to content

Use List.Sort for ordered dictionary output - #345

Merged
SimonCropp merged 1 commit into
mainfrom
Use-List.Sort-for-ordered-dictionary-output
Feb 7, 2026
Merged

Use List.Sort for ordered dictionary output#345
SimonCropp merged 1 commit into
mainfrom
Use-List.Sort-for-ordered-dictionary-output

Conversation

@SimonCropp

Copy link
Copy Markdown
Member

Replace the local iterator + LINQ OrderBy with building a List and sorting it in-place before serialization. For string keys the list is sorted with StringComparer.OrdinalIgnoreCase, otherwise with Comparer.Default, and then each entry is serialized. This simplifies the code, removes the static Items iterator, and reduces allocation/iteration overhead when serializing ordered dictionaries.

Replace the local iterator + LINQ OrderBy with building a List<DictionaryEntry> and sorting it in-place before serialization. For string keys the list is sorted with StringComparer.OrdinalIgnoreCase, otherwise with Comparer.Default, and then each entry is serialized. This simplifies the code, removes the static Items iterator, and reduces allocation/iteration overhead when serializing ordered dictionaries.
@SimonCropp SimonCropp added this to the 0.33.1 milestone Feb 7, 2026
@SimonCropp
SimonCropp merged commit 852a492 into main Feb 7, 2026
4 of 5 checks passed
SimonCropp added a commit that referenced this pull request Feb 8, 2026
@SimonCropp
SimonCropp deleted the Use-List.Sort-for-ordered-dictionary-output branch August 14, 2026 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant