Skip to content

Alphabetical ordering is not preserved when inserting in a single-element map #2258

@sigurdm

Description

@sigurdm

can you provide a reproduction?

Create a pubspec with no dependencies, then do:

dart pub add path
dart pub add async

You end up with:

dependencies:
  path: ^1.9.1
  async: ^2.13.0

This logic looks wrong to me, it always appends if there is one existing item, rather than assuming it should be alphabetical?

// We can't deduce ordering if list is empty, so then we just we just append
if (keys.length <= 1) {
return map.length;
}

  // We can't deduce ordering if list is empty, so then we just we just append
  if (keys.length <= 1) {
    return map.length;
  }

Originally posted by @DanTup in #4710

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions