tc39 / proposal-record-tuple

ECMAScript proposal for the Record and Tuple value types. | Stage 2: it will change!
https://tc39.es/proposal-record-tuple/
2.48k stars 62 forks source link

Question about the implicitly-sorted-rule of key #389

Open navegador5 opened 1 month ago

navegador5 commented 1 month ago

the document mentioned:

Insertion order of record keys does not affect equality of records, 
because there's no way to observe the original ordering of the keys, as they're implicitly sorted:

what is the sort rule? A or B ?

_A. first sort index-like keys : ("1", "15", "6"... ), then others ["aa","bb","cc"]__ B.just sort them together : [1,15, 6, "aa","bb","cc"]

acutmore commented 1 month ago

The keys are sorted as strings ("11" < "2" === true). No preference is given to integer index like strings.

https://github.com/tc39/proposal-record-tuple/blob/5c9a6e144c687ef5911f4c0c088bc21343cbaf68/spec/abstract-operations.html#L915

for any entry two entries a and b, a will be placed before b if the result of performing Abstract Relational Comparison a.[[Key]] < b.[[Key]] is true.