Skip to content

add option to sort maps by key#110

Closed
beatt83 wants to merge 1 commit intovalpackett:masterfrom
beatt83:feature/add_map_sort_option
Closed

add option to sort maps by key#110
beatt83 wants to merge 1 commit intovalpackett:masterfrom
beatt83:feature/add_map_sort_option

Conversation

@beatt83
Copy link
Copy Markdown
Contributor

@beatt83 beatt83 commented Nov 22, 2024

Hi there.

To contribute I added this option that I found to be useful so before encoding the encoder first sorts the keys. I found a similar logic was already being used for Map<CBOREncodable, Any> so I added the option so maps are sorted by key.

So it doesn't cause any breaking change this flag is set to true by default.

@obinns-dd
Copy link
Copy Markdown

@hamchapman any chance we can look to get this one merged?

It looks like it solves #104 and it's would help a lot of folks (including myself).

Also related to but not exactly solving the issue of OrderedDictionary: #96.

@beatt83
Copy link
Copy Markdown
Contributor Author

beatt83 commented Aug 29, 2025

@obinns-dd I had forgotten that I created this PR, since it is almost close to a year now. I can probably update my fork repo and create a release version, so it can be used by others.

so it does not introduce breaking changes this flag is set as default to true

Signed-off-by: Goncalo Frade <goncalofrade08@gmail.com>
@beatt83 beatt83 force-pushed the feature/add_map_sort_option branch from fca4773 to c634481 Compare August 29, 2025 13:13
@beatt83
Copy link
Copy Markdown
Contributor Author

beatt83 commented Aug 29, 2025

@obinns-dd here you go. Its updated with last changes and it has the sort order, I know not ideal but its the best I can do to help: https://github.com/beatt83/SwiftCBOR/releases/tag/0.5.1

@hamchapman
Copy link
Copy Markdown
Collaborator

Thanks a lot for the PR and sorry it's taken so long for it to be engaged with. I'm closing this one as I've incorporated it into #121.


Closing as superseded by:

@hamchapman hamchapman closed this Dec 13, 2025
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.

3 participants