Use slices.Sorted(maps.Keys(...)) to replace collect-keys-then-sort pattern#4954
Open
pietern wants to merge 2 commits intogo1.21-slices-packagefrom
Open
Use slices.Sorted(maps.Keys(...)) to replace collect-keys-then-sort pattern#4954pietern wants to merge 2 commits intogo1.21-slices-packagefrom
slices.Sorted(maps.Keys(...)) to replace collect-keys-then-sort pattern#4954pietern wants to merge 2 commits intogo1.21-slices-packagefrom
Conversation
… pattern Go 1.23 added `slices.Sorted` which accepts an iterator and returns a sorted slice. Combined with `maps.Keys`, this replaces the common three-step pattern of allocating a slice, collecting keys, then sorting. This removes the `utils.SortedKeys` helper and two package-local duplicates (`sortedKeys`, `sortKeys`), inlining all call sites with the stdlib one-liner. Co-authored-by: Isaac
renaudhartert-db
approved these changes
Apr 13, 2026
Co-authored-by: Isaac
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.
Summary
slices.Sorted(maps.Keys(...))utils.SortedKeysand two package-local duplicates (sortedKeys,sortKeys), inlining all call sitesslices.Collect(maps.Values(...))+slices.Sort(...)withslices.Sorted(maps.Values(...))indynloc/locations.goTest plan
go build ./...passesThis pull request was AI-assisted by Isaac.