Performance Comparison of various sort operations in JavaScript

Source: Internet
Author: User
Sorting is a commonly used programming example. what is the performance of various sorting in JavaScript? The data tested by each browser is different. For example, if I use chrome for testing, the fast sorting will usually be the fastest, and IE may be the fastest in the Shile according to the array length. Do not use too much data to test the bubble sorting (I don't care if the browser crashes ).

Sorting is a commonly used programming example. what is the performance of various sorting in JavaScript? The data tested by each browser is different. For example, if I use chrome for testing, the fast sorting will usually be the fastest, and IE may be the fastest in the Shile according to the array length.

Do not use too much data to test the bubble sorting (I don't care if the browser crashes ).

[,] Quick sorting Insert sort Hill Sorting System Method Bubble sorting ClearTest array length:
Number of Tests: 10
The array is too long. please use bubble sort with caution.
Algorithm Array length Time difference (MS) Average (MS) Click Test
Quick sorting Test
Insert sort Test
Hill Sorting Test
System Method Test
Bubble sorting Test with caution

Personal understanding:

  • Bubble sorting: the simplest and slowest. it seems that the length is smaller than 7.
  • Insert sorting: it is faster than bubble, and slower than fast sorting and Hill sorting. smaller data has advantages.
  • Fast sorting: this is a very fast sorting method. the V8 sort method uses the combination of fast sorting and insert sorting.
  • Hill Sorting: In non-chrome, the array length is less than 1000, and the Hill sorting is faster
  • System Method: The system method in forfox is very fast.
JavaScript Code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.