The idea is to practically find out what sorting algorithm is used by JavaScript's built-in Array.prototype.sort()
method by comparing its performance with other sorting algorithms on various of input.
The following sorting algorithms are implemented and used for benchmarking at the moment:
- Insertion Sort
- Quick sort
- Quick sort with random pivot
- Merge sort
- Counting sort (since array elements are integers)
npm run test
Based on the results on random and descending input, it seems that JavaScript's built-in Array.prototype.sort()
method might be using Quick sort with additional optimizations on reverse sorted input