3 ms·
The 'long tail' really oughtn't be that long if they switched to the native sort when a partition becomes small enough.
by KayEss 11y ago
The 'long tail' really oughtn't be that long if they switched to the native sort when a partition becomes small enough.
- girvo 11y ago> switched to the native sort when a partition becomes small enough Isn't that exactly what they are doing? >> Our approach was simply to prefer the native implementation unless working in IE8 or with arrays over a thousand items.
- gpvos 11y agoI understood that they chose between the two versions at the top level, not at lower levels.
- drostie 11y agoThat's going to be tricky to do with quicksort... you could definitely do it with mergesort, though, but you'd have to abandon the in-place guarantee. The basic problem is that Array.prototype.sort() does not accept indexes for a slice of the array to sort between.
- KayEss 11y agoIt's simple enough if you split the list at the partition point, but hard if you do it in place.