On Fri, Mar 18, 2016 at 3:57 PM, Waldemar Horwat <[email protected]> wrote: > On 03/18/2016 11:10, Tab Atkins Jr. wrote: >> >> If you're planning on pessimistically assuming that legacy >> implementations use an unstable sort for Array#sort(), then testing >> for the presence of Array#fastSort() (and assuming that when it >> appears the Array#sort is stable) is exactly as useful as testing for >> the presence of Array#stableSort (and assuming that when it appears >> the Array#sort is unstable/fast). So, polyfilling isn't a reason to >> prefer one default vs the other. > > That makes no sense. The presence of fastSort does not indicate that sort > is stable.
I'm confused. Did you miss some context here? No UA currently provides an Array#fastSort. We'd only do so if the method was added to the spec; such a method would only be added to the spec if we also changed the spec to require Array#sort to be stable. So yes, the presence of Array#fastSort is a positive signal for Array#sort being stable. Just like the presence of Array#stableSort is a positive signal for Array#sort *not* being stable. Exception proves the rule, etc. > The approach of sometimes using "sort" for unstable sort and sometimes for > stable sort would cause too much confusion. Which sort are you getting when > you call sort? If you want a sort that's guaranteed stable, call > stableSort. Again, in the context that I was replying to, we're talking about a polyfill. Said polyfill would ensure that legacy implementations got a stable sort filled in for Array#sort. > The argument that stable sort should have the shorter name doesn't hold much > water either. C++ defines sorts named sort and stable_sort (as well as a > few others) just fine. sort is by far the more popular one (by a factor of > 20!) because most applications don't actually care about stability. Or because most people reach for the familiar short name by default. Usability directly impacts use, and most coders are familiar with only a small fraction of the standard library. I'd bet quite a lot of applications actually *do* care about stability, but such situations only crop up rarely in practice, and so they're just occasionally buggy. ~TJ _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

