Option in the cbor2 playground
The sortKeys pulldown in the cbor2 playground has three options: null, coreDeterministic, lengthFirstDeterministic.
Current behavior
Regardless of the setting, the following map is encoded in the input order of its keys
{
[1, 2, 3]: true,
257: true,
"a": true
}
Expected behavior
sortKeys = null: input order (as expected)
sortKeys = coreDeterministic: expected to sort the map keys in lexicographic order according to the rules of Section 4.2.1 of RFC 8949.
The output would be the same as:
257: true,
"a": true,
[1, 2, 3]: true
Quoting that section:
The keys in every map MUST be sorted in the bytewise lexicographic order of their deterministic encodings. For example, the following keys are sorted correctly:
- 10, encoded as 0x0a.
- 100, encoded as 0x1864.
- -1, encoded as 0x20.
- "z", encoded as 0x617a.
- "aa", encoded as 0x626161.
- [100], encoded as 0x811864.
- [-1], encoded as 0x8120.
- false, encoded as 0xf4.
sortKeys = lengthFirstDeterministic: expected to sort the map keys in length-first, then lexicographic order of the value omitting the first 3-bit of the major as poorly described in the third bullet item of Section 3.9 of RFC7049.
The output would be the same as:
"a": true,
257: true,
[1, 2, 3]: true
Option in the cbor2 playground
The sortKeys pulldown in the cbor2 playground has three options:
null,coreDeterministic,lengthFirstDeterministic.Current behavior
Regardless of the setting, the following map is encoded in the input order of its keys
Expected behavior
sortKeys = null: input order (as expected)
sortKeys = coreDeterministic: expected to sort the map keys in lexicographic order according to the rules of Section 4.2.1 of RFC 8949.
The output would be the same as:
Quoting that section:
The keys in every map MUST be sorted in the bytewise lexicographic order of their deterministic encodings. For example, the following keys are sorted correctly:
sortKeys = lengthFirstDeterministic: expected to sort the map keys in length-first, then lexicographic order of the value omitting the first 3-bit of the major as poorly described in the third bullet item of Section 3.9 of RFC7049.
The output would be the same as: