The V8 engine in Chrome 70 introduced a significant update to Array.prototype.sort by switching from Quicksort to Timsort. Timsort, an adaptive stable algorithm, offers better performance in most cases and handles already sorted sequences efficiently. The post details the quirks of sorting in JavaScript, pre- and post-processing steps in V8, and how the implementation in Torque—a domain-specific language—improves stability and performance predictability. This change addresses long-standing issues and aligns with algorithmic guarantees for better user experiences.

17m read timeFrom v8.dev
Post cover image
Table of contents
Background #History #Timsort #Conclusion #

Sort: