In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "JavaScript how to sort multi-dimensional array multi-key values", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in-depth, together to study and learn "JavaScript how to sort multi-dimensional array multi-key values" bar!
The method of sorting Multi-key values in Multi-dimensional arrays by JavaScript
The sort method of the array sort function of JavaScript, which is sorted in ascending order according to the ASCII character order by default.
Arrayobj.sort (sortfunction)
Parameter: sortFunction
Optional. Is the name of the function used to determine the order of the elements. If this parameter is omitted, the elements will be sorted in ascending order in ASCII character order.
The sort method sorts the Array objects appropriately; no new Array objects are created during execution.
If a function is provided for the sortfunction parameter, the function must return one of the following values:
Negative value, if the passed * parameter is smaller than the second parameter.
Zero, if the two parameters are equal.
A positive value if the * parameter is larger than the second parameter.
The above methods are convenient for one-dimensional sorting, but how to do multi-key value sorting like ORDERBY in SQL statements?
The sorting of multi-key values in multidimensional arrays needs to be a little more complicated, but it does not need to be solved by loops. The truth of the actual solution is the same.
Number:
The following example is to sort a multidimensional array of numbers in the order of column 5, column 9, and column 3, like ORDERBYcol5,col9,col7 in the SQL statement. The number can be directly subtracted from the two items, and the result can be used as the return value.
VarmyArray=newArray (); for (vari=0;i
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.