Open
Description
In Array.p.sort
, if _comparefn_
is *undefined*
, items are compared by comparing their ToString
results. Rather than calling ToString
twice per call to SortCompare, it seems like an implementation might want to call ToString
on each item exactly once, sort the resulting strings, and then arrange the original items accordingly (aka the decorate-sort-undecorate pattern).
However, calls to ToString
can be observed, and this optimization would definitely change the number of those calls (from roughly 2 n log(n) to just n). So does that mean that this optimization is non-compliant? (If so, do implementations use it anyway?)