Sort syntax: Arrayobject.sort (sortby), parameter SortBy Optional. Specifies the sort order. Must be a function.
Because the sort method is to compare array elements to strings first, and then to compare them according to the ASCII code of the first character of the string, it is not possible to satisfy the ordering requirements of our array of numeric sets, but the sort () method can use the function to sort the array by the bubbling method. My personal understanding is that if you want to sort it, the given function has the following two forms:
Array.Sort (function(b) { A-b;})
This method is implemented from a small to a large sort.
Array.Sort (function(A, b ) {return B-A; })
This method can be implemented from a large to a small sort.
If you sort a multidimensional array, you should give the subscript of the sort.
In addition, JavaScript's sorting method also has the reverse () method, which can act as a reverse array.
A summary of the JavaScript array sort () method