Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why map.js sort keys? #185

Open
start940315 opened this issue Jan 17, 2024 · 1 comment
Open

Why map.js sort keys? #185

start940315 opened this issue Jan 17, 2024 · 1 comment
Labels
enhancement New feature or request port-fix triaged Issue has been triaged

Comments

@start940315
Copy link

In some situation, I need to generate different result according to different order that items are inserted. But I read your code and find that you sort the key order, which generate the same result on different order. Can you change the behavior?

@dibenede
Copy link
Contributor

According to the official protobuf spec, map iteration order is undefined. To my knowledge, some implementations do implement insertion order while others (notably golang) do not.

This is something we could potentially change in the future, but you are better off using a repeated field if a particular order matters to you.

@dibenede dibenede added enhancement New feature or request triaged Issue has been triaged port-fix labels Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request port-fix triaged Issue has been triaged
Projects
None yet
Development

No branches or pull requests

2 participants