Skip to content

rendered keys of an object should be sorted alphanumerically #228

@derrickburns

Description

@derrickburns

When arrays are turned into JSON, they are represented as objects where the keys are numbers, e.g.

x {
foo = [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k" ]
}

is equivalent to

x { foo {
"0": "a"
"1": "b"
"2": "c"
"3": "d"
"4": "e"
"5": "f"
"6": "g"
"7": "h"
"8": "i"
"9": "j"
"10": "k"
} }

Unfortunately, when rendered this will appear as:

x { foo {
"0": "a"
"1": "b"
"10": "k"
"2": "c"
"3": "d"
"4": "e"
"5": "f"
"6": "g"
"7": "h"
"8": "i"
"9": "j"
} }

The keys are sorted using the default sort. They should be sorted using an alphanumerical comparator.

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