Algorithms and Data Structures · Middle · Question 6 of 75
Which sorting algorithm does V8 use for Array.prototype.sort?
- ✓Correct answer: Timsort
- 2Plain quicksort
- 3Bubble sort
Explanation
Since 2018 (V8 7.0) sort uses Timsort: a hybrid of merge sort and insertion sort that finds already sorted runs. It's stable and O(n log n) in the worst case, and close to O(n) on nearly sorted data.