Algorithms and Data Structures · Middle · Question 6 of 75

Which sorting algorithm does V8 use for Array.prototype.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.

Further reading

Problem with a question

Algorithms and Data Structures · Middle · question 6

Test yourself

Take the Algorithms and Data Structures · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz