In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to use js array sorting method sort". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use the js array sorting method sort.
1. Sort () method
Arranges the elements in the js array in a certain order.
2. Grammar
Array.sort (fun)
3. Parameters
Fun: optional. Specify the sort order. Must be a function.
4. Return value
If an is less than b and a should appear before b in the sorted array, a value less than 0 is returned.
If an equals b, 0 is returned.
If an is greater than b, a value greater than 0 is returned.
Note:
Using the sort () method takes no arguments and sorts the elements in the array alphabetically.
When you use the sort () method to have arguments, the function compares two values and returns a number that describes the relative order of the two values. The comparison function should have the above two parameters an and b.
5. Use example: use js array sorting method sort () method to sort.
Var myarr1 = new Array ("Hello", "John", "love", "JavaScript"); var myarr2 = new Array ("80", "16", "50", "6", "100", "1"); [xss_clean] (myarr1.sort () + "
[xss_clean] (myarr2.sort ())
Output
Hello,JavaScript,John,love 1meme 100je 16je 50je 6je 80 to here, I believe that everyone on the "js array sorting method sort how to use" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.