Array.Sort Google core array size more than 10 sorted fields are returned in an array that is not the original array

Source: Internet
Author: User
Tags array length

1. If the data size is less than or equal to 10 is normal

2. Data size greater than 10

Implementation principle of Array.Sort in 3.js

Definition: the sort () method is used to sort the elements of an array.
API syntax: Arrayobject.sort (sortby), parameter SortBy optional, used to specify collation, must be a function.
How is it implemented?
The V8 engine sort function gives only two sorts: Insertionsort and QuickSort, the array length is less than or equal to 10 with the insertion sort insertionsort, and the 10 larger array uses the Quick sort QuickSort
Address: Https://github.com/v8/v8/blob/master/src/js/array.js
Mozilla/firefox: Merge sort (jsarray.c source)
Webkit: The underlying implementation uses the Qsort () method in the C + + library (JSArray.cpp source code)

Reference Link: http://blog.csdn.net/coder_chenz/article/details/77156047

Array.Sort Google core array size more than 10 sorted fields are returned in an array that is not the original array

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.