Skip to content

Why map.js sort keys? #185

Open
Open

Description

@start940315

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?

Activity

  1. dibenede commented on Jan 17, 2024

    @dibenede
    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions